[PATCH 2/2] Maintab: prevent a segfault in the 'Equipment' tab

Lubomir I. Ivanov neolit123 at gmail.com
Fri Jan 3 13:11:04 UTC 2014


On 3 January 2014 14:49, Lubomir I. Ivanov <neolit123 at gmail.com> wrote:
> From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
>
> 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 at gmail.com>
> ---
>
>     newEditMode=MainTab::NONE) at qt-ui/maintab.cpp:225
>     at qt-ui/maintab.cpp:546
> ...
> ---
>  qt-ui/maintab.cpp | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
> index 4fc543f..8da1137 100644
> --- a/qt-ui/maintab.cpp
> +++ b/qt-ui/maintab.cpp
> @@ -223,6 +223,7 @@ void MainTab::enableEdition(EditMode newEditMode)
>         if (current_dive == NULL || editMode != NONE)
>                 return;
>         if ((newEditMode == DIVE || newEditMode == NONE) &&
> +           current_dive->dc.model &&
>             strcmp(current_dive->dc.model, "manually added dive") == 0) {
>                 // editCurrentDive will call enableEdition with newEditMode == MANUALLY_ADDED_DIVE
>                 // so exit this function here after editCurrentDive() returns
> --
> 1.7.11.msysgit.0
>


this one is a real bug btw.
i think it happens with some auto-generated dives that i had for the
print testing.
it reaches a NULL current_dive->dc.model.

<divelog program='subsurface' version='2'>
<settings>
<divecomputerid model='Model Product' deviceid='e04d0248'
nickname='Model Product (e04d0248)'/>
</settings>
<dives>
<dive date='1989-05-17' time='09:00:00' duration='10:00 min'>
  <location>219</location>
  <notes>notes</notes>
  <divecomputer>
  <depth max='219.0 m' mean='15.0 m' />
  </divecomputer>
</dive>
...

lubomir
--


More information about the subsurface mailing list