From f8e9c975b78c78d1faacfbf65a1ab768bf9d136f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 3 Oct 2015 07:19:55 -0400 Subject: [PATCH] Use copy_string() to avoid potential crash If the trip has no location or notes calling strdup on NULL is just a bad idea. Signed-off-by: Dirk Hohndel --- qt-ui/undocommands.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qt-ui/undocommands.cpp b/qt-ui/undocommands.cpp index dbfc77472..0fd182cb3 100644 --- a/qt-ui/undocommands.cpp +++ b/qt-ui/undocommands.cpp @@ -47,8 +47,8 @@ void UndoDeleteDive::redo() if (d->divetrip && d->divetrip->nrdives == 1) { struct dive_trip *undo_trip = (struct dive_trip *)calloc(1, sizeof(struct dive_trip)); *undo_trip = *d->divetrip; - undo_trip->location = strdup(d->divetrip->location); - undo_trip->notes = strdup(d->divetrip->notes); + undo_trip->location = copy_string(d->divetrip->location); + undo_trip->notes = copy_string(d->divetrip->notes); undo_trip->nrdives = 0; undo_trip->next = NULL; undo_trip->dives = NULL;