From 75007aa4ef7b99064678ff92ec9819e76f553cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20Cu=C3=B1at?= Date: Wed, 12 Apr 2017 21:54:47 +0200 Subject: [PATCH] smtk-import reuse pre-existent code and fix leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use update_event_name() for bookmarks merge and free temp string. Signed-off-by: Salvador Cuñat --- smtk-import/smartrak.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/smtk-import/smartrak.c b/smtk-import/smartrak.c index ba38c6b33..a50186b3d 100644 --- a/smtk-import/smartrak.c +++ b/smtk-import/smartrak.c @@ -687,15 +687,15 @@ static void smtk_parse_bookmarks(MdbHandle *mdb, struct dive *d, char *dive_idx) time = lrint(strtod(col[4]->bind_ptr, NULL) * 60); tmp = strdup(col[2]->bind_ptr); ev = find_bookmark(d->dc.events, time); - if (ev != NULL) { - memset(&ev->name, 0, strlen(tmp) + 1); - memcpy(ev->name, tmp, strlen(tmp)); - } else + if (ev) + update_event_name(d, ev, tmp); + else if (!add_event(&d->dc, time, SAMPLE_EVENT_BOOKMARK, 0, 0, tmp)) report_error("[smtk-import] Error - Couldn't add bookmark, dive %d, Name = %s", d->number, tmp); } } + free(tmp); smtk_free(bound_values, table->num_cols); mdb_free_tabledef(table); }