diff options
-rw-r--r-- | file.c | 8 | ||||
-rw-r--r-- | libdivecomputer.c | 5 | ||||
-rw-r--r-- | load-git.c | 6 | ||||
-rw-r--r-- | parse-xml.c | 9 | ||||
-rw-r--r-- | planner.c | 1 | ||||
-rw-r--r-- | qt-models/diveplannermodel.cpp | 1 | ||||
-rw-r--r-- | qt-ui/maintab.cpp | 2 | ||||
-rw-r--r-- | uemis-downloader.c | 5 |
8 files changed, 26 insertions, 11 deletions
@@ -547,11 +547,12 @@ int parse_txt_file(const char *filename, const char *csv) struct divecomputer *dc; struct tm cur_tm; - if (sscanf(parse_mkvi_value(memtxt.buffer, "Dive started at"), "%d-%d-%d %d:%d:%d", - &y, &m, &d, &hh, &mm, &ss) != 6) { + value = parse_mkvi_value(memtxt.buffer, "Dive started at"); + if (sscanf(value, "%d-%d-%d %d:%d:%d", &y, &m, &d, &hh, &mm, &ss) != 6) { + free(value); return -1; } - + free(value); cur_tm.tm_year = y; cur_tm.tm_mon = m - 1; cur_tm.tm_mday = d; @@ -622,6 +623,7 @@ int parse_txt_file(const char *filename, const char *csv) */ if (readfile(csv, &memcsv) < 0) { + free(dive); return report_error(translate("gettextFromC", "Poseidon import failed: unable to read '%s'"), csv); } lineptr = memcsv.buffer; diff --git a/libdivecomputer.c b/libdivecomputer.c index 6b7874d82..ef6e4f871 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -461,7 +461,10 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, struct device_data_t } // Parse the divetime. - dev_info(devdata, translate("gettextFromC", "Dive %d: %s"), import_dive_number, get_dive_date_c_string(dive->when)); + const char *date_string = get_dive_date_c_string(dive->when); + dev_info(devdata, translate("gettextFromC", "Dive %d: %s"), import_dive_number, date_string); + free((void *)date_string); + unsigned int divetime = 0; rc = dc_parser_get_field(parser, DC_FIELD_DIVETIME, 0, &divetime); if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) { diff --git a/load-git.c b/load-git.c index bd64da478..932eb50a5 100644 --- a/load-git.c +++ b/load-git.c @@ -184,9 +184,10 @@ static void parse_dive_gps(char *line, struct membuffer *str, void *_dive) } else { if (dive_site_has_gps_location(ds) && (ds->latitude.udeg != latitude.udeg || ds->longitude.udeg != longitude.udeg)) { + const char *coords = printGPSCoords(latitude.udeg, longitude.udeg); // we have a dive site that already has GPS coordinates - ds->notes = add_to_string(ds->notes, translate("gettextFromC", "multiple gps locations for this dive site; also %s\n"), - printGPSCoords(latitude.udeg, longitude.udeg)); + ds->notes = add_to_string(ds->notes, translate("gettextFromC", "multiple gps locations for this dive site; also %s\n"), coords); + free((void *)coords); } ds->latitude = latitude; ds->longitude = longitude; @@ -218,6 +219,7 @@ static void parse_dive_location(char *line, struct membuffer *str, void *_dive) ds->notes = add_to_string(ds->notes, translate("gettextFromC", "additional name for site: %s\n"), name); } } + free(name); } static void parse_dive_divemaster(char *line, struct membuffer *str, void *_dive) diff --git a/parse-xml.c b/parse-xml.c index 0e8e3a556..9b5f97e21 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -1204,8 +1204,9 @@ static void gps_in_dive(char *buffer, struct dive *dive) fprintf(stderr, "dive site uuid in dive, but gps location (%10.6f/%10.6f) different from dive location (%10.6f/%10.6f)\n", ds->latitude.udeg / 1000000.0, ds->longitude.udeg / 1000000.0, latitude.udeg / 1000000.0, longitude.udeg / 1000000.0); - ds->notes = add_to_string(ds->notes, translate("gettextFromC", "multiple gps locations for this dive site; also %s\n"), - printGPSCoords(latitude.udeg, longitude.udeg)); + const char *coords = printGPSCoords(latitude.udeg, longitude.udeg); + ds->notes = add_to_string(ds->notes, translate("gettextFromC", "multiple gps locations for this dive site; also %s\n"), coords); + free((void *)coords); } else { fprintf(stderr, "let's add the gps coordinates to divesite with uuid %8x and name %s\n", ds->uuid, ds->name ?: "(none)"); ds->latitude = latitude; @@ -1220,6 +1221,7 @@ static void add_dive_site(char *ds_name, struct dive *dive) { static int suffix = 1; char *buffer = ds_name; + char *to_free = NULL; fprintf(stderr, "add_dive_site with name %s\n", buffer); int size = trimspace(buffer); if(size) { @@ -1238,7 +1240,7 @@ static void add_dive_site(char *ds_name, struct dive *dive) // get a lot of dives with identical names (the autogenerated fixes). // So in this case modify the name to make it unique int name_size = strlen(buffer) + 10; // 8 digits - enough for 100 million sites - buffer = malloc(name_size); + to_free = buffer = malloc(name_size); do { suffix++; snprintf(buffer, name_size, "%s %8d", ds_name, suffix); @@ -1276,6 +1278,7 @@ static void add_dive_site(char *ds_name, struct dive *dive) dive->dive_site_uuid = create_dive_site(buffer); } } + free(to_free); } static void gps_picture_location(char *buffer, struct picture *pic) @@ -837,6 +837,7 @@ bool trial_ascent(int trial_depth, int stoplevel, int avg_depth, int bottom_time trial_depth -= deltad; } restore_deco_state(trial_cache); + free(trial_cache); return clear_to_ascend; } diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 655f1bd8b..a4ca14715 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -882,6 +882,7 @@ void DivePlannerPointsModel::createPlan(bool replanCopy) //TODO: C-based function here? bool did_deco = plan(&diveplan, &cache, isPlanner(), true); + free(cache); if (!current_dive || displayed_dive.id != current_dive->id) { // we were planning a new dive, not re-planning an existing on record_dive(clone_dive(&displayed_dive)); diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 8b141a16f..c6660fc6b 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -1184,6 +1184,8 @@ void MainTab::saveTags() taglist_free(mydive->tag_list); mydive->tag_list = new_tag_list; ); + taglist_free(added_list); + taglist_free(removed_list); } // buddy and divemaster are represented in the UI just like the tags, but the internal diff --git a/uemis-downloader.c b/uemis-downloader.c index 986aeb5b3..d14e6e7c6 100644 --- a/uemis-downloader.c +++ b/uemis-downloader.c @@ -534,6 +534,7 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in, snprintf(fl, 13, "ANS%d.TXT", assembling_mbuf ? filenr - 2 : filenr - 1); ans_path = build_filename(build_filename(path, "ANS"), fl); ans_file = subsurface_open(ans_path, O_RDONLY, 0666); + free(ans_path); size = bytes_available(ans_file); if (size > 3) { char *buf; @@ -564,6 +565,7 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in, snprintf(fl, 13, "ANS%d.TXT", filenr - 1); ans_path = build_filename(build_filename(path, "ANS"), fl); ans_file = subsurface_open(ans_path, O_RDONLY, 0666); + free(ans_path); size = bytes_available(ans_file); if (size > 3) { int r; @@ -578,12 +580,11 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in, buffer_add(&mbuf, &mbuf_size, buf); show_progress(buf, what); #if UEMIS_DEBUG & 8 - fprintf(debugfile, "::r %s \"%s\"\n", ans_path, buf); + fprintf(debugfile, "::r %s \"%s\"\n", fl, buf); #endif } size -= 3; close(ans_file); - free(ans_path); } else { ismulti = false; } |