mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Cleanup: better handling of NULL dive in setCurrentDiveSite
We test for d being NULL so that's clearly an option we worried about, yet we already called get_dive_site_for_dive(d) which dereferences d. Found by Coverity. Fixes CID 350118 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1951371bbb
commit
130534aedf
1 changed files with 9 additions and 5 deletions
|
@ -567,14 +567,18 @@ void DiveLocationLineEdit::fixPopupPosition()
|
|||
|
||||
void DiveLocationLineEdit::setCurrentDiveSite(struct dive *d)
|
||||
{
|
||||
struct dive_site *ds = get_dive_site_for_dive(d);
|
||||
currDs = ds;
|
||||
location_t currentLocation;
|
||||
if (d) {
|
||||
currDs = get_dive_site_for_dive(d);
|
||||
currentLocation = dive_get_gps_location(d);
|
||||
} else {
|
||||
currDs = nullptr;
|
||||
currentLocation = location_t{0, 0};
|
||||
}
|
||||
if (!currDs)
|
||||
clear();
|
||||
else
|
||||
setText(ds->name);
|
||||
|
||||
location_t currentLocation = d ? dive_get_gps_location(d) : location_t{0, 0};
|
||||
setText(currDs->name);
|
||||
proxy->setCurrentLocation(currentLocation);
|
||||
delegate.setCurrentLocation(currentLocation);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue