maintab.cpp: use copy_string() instead of strdup()

The .location and .notes fields can end up being NULL,
in which case copy_string() is safer.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Lubomir I. Ivanov 2014-11-11 21:41:47 +02:00 committed by Dirk Hohndel
parent d06cc2c68e
commit 200699706e

View file

@ -691,11 +691,11 @@ void MainTab::acceptChanges()
} else if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) {
/* now figure out if things have changed */
if (!same_string(displayedTrip.notes, currentTrip->notes)) {
currentTrip->notes = strdup(displayedTrip.notes);
currentTrip->notes = copy_string(displayedTrip.notes);
mark_divelist_changed(true);
}
if (!same_string(displayedTrip.location, currentTrip->location)) {
currentTrip->location = strdup(displayedTrip.location);
currentTrip->location = copy_string(displayedTrip.location);
mark_divelist_changed(true);
}
currentTrip = NULL;