diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-10-03 07:19:55 -0400 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-10-03 07:19:55 -0400 |
commit | f8e9c975b78c78d1faacfbf65a1ab768bf9d136f (patch) | |
tree | 3d7b769509d52a62175eefac9f8f10f660c0be98 /qt-ui | |
parent | c30dfba433eb6e46d88a0c25cea7c4f47cb55f33 (diff) | |
download | subsurface-f8e9c975b78c78d1faacfbf65a1ab768bf9d136f.tar.gz |
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/undocommands.cpp | 4 |
1 files 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; |