Maintab: prevent a segfault in the 'Equipment' tab

When a dive contains no cylinders, clicking the '+'
button could SIGSEGV if current_dive->dc.model is NULL.

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-01-03 14:49:17 +02:00 committed by Dirk Hohndel
parent 7771158c82
commit 6719e45704

View file

@ -223,6 +223,7 @@ void MainTab::enableEdition(EditMode newEditMode)
if (current_dive == NULL || editMode != NONE) if (current_dive == NULL || editMode != NONE)
return; return;
if ((newEditMode == DIVE || newEditMode == NONE) && if ((newEditMode == DIVE || newEditMode == NONE) &&
current_dive->dc.model &&
strcmp(current_dive->dc.model, "manually added dive") == 0) { strcmp(current_dive->dc.model, "manually added dive") == 0) {
// editCurrentDive will call enableEdition with newEditMode == MANUALLY_ADDED_DIVE // editCurrentDive will call enableEdition with newEditMode == MANUALLY_ADDED_DIVE
// so exit this function here after editCurrentDive() returns // so exit this function here after editCurrentDive() returns