mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: NULL check pointer before dereferencing
Found by Coverity. CID 350081, 350087, 350095 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
08fcda60ac
commit
33137c62b0
2 changed files with 5 additions and 4 deletions
|
@ -3275,11 +3275,12 @@ int split_dive(const struct dive *dive, struct dive **new1, struct dive **new2)
|
||||||
int split_dive_at_time(const struct dive *dive, duration_t time, struct dive **new1, struct dive **new2)
|
int split_dive_at_time(const struct dive *dive, duration_t time, struct dive **new1, struct dive **new2)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
struct sample *sample = dive->dc.sample;
|
|
||||||
|
|
||||||
*new1 = *new2 = NULL;
|
|
||||||
if (!dive)
|
if (!dive)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
struct sample *sample = dive->dc.sample;
|
||||||
|
*new1 = *new2 = NULL;
|
||||||
while(sample->time.seconds < time.seconds) {
|
while(sample->time.seconds < time.seconds) {
|
||||||
++sample;
|
++sample;
|
||||||
++i;
|
++i;
|
||||||
|
@ -3670,7 +3671,7 @@ static void delete_divecomputer(struct dive *d, int num)
|
||||||
struct divecomputer *pdc = &d->dc;
|
struct divecomputer *pdc = &d->dc;
|
||||||
for (i = 0; i < num - 1 && pdc; i++)
|
for (i = 0; i < num - 1 && pdc; i++)
|
||||||
pdc = pdc->next;
|
pdc = pdc->next;
|
||||||
if (pdc->next) {
|
if (pdc && pdc->next) {
|
||||||
struct divecomputer *dc = pdc->next;
|
struct divecomputer *dc = pdc->next;
|
||||||
pdc->next = dc->next;
|
pdc->next = dc->next;
|
||||||
free_dc(dc);
|
free_dc(dc);
|
||||||
|
|
|
@ -377,7 +377,7 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o
|
||||||
dive_site *site = dive->dive_site;
|
dive_site *site = dive->dive_site;
|
||||||
QRegExp ct("countrytag: (\\w+)");
|
QRegExp ct("countrytag: (\\w+)");
|
||||||
QString country;
|
QString country;
|
||||||
if (ct.indexIn(site->notes) >= 0)
|
if (site && ct.indexIn(site->notes) >= 0)
|
||||||
country = ct.cap(1);
|
country = ct.cap(1);
|
||||||
else
|
else
|
||||||
country = "";
|
country = "";
|
||||||
|
|
Loading…
Add table
Reference in a new issue