diff options
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 9 |
1 files changed, 6 insertions, 3 deletions
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) |