Cleanup: avoid dereferencing NULL pointer

Coverity CID 208330
Coverity CID 208301

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-12-27 22:11:00 -08:00
parent e8719413a7
commit 6cc5b601aa

View file

@ -927,6 +927,11 @@ int parse_dan_format(const char *filename, char **params, int pnr)
++iter;
}
if (!iter) {
fprintf(stderr, "DEBUG: Data corrupt");
return -1;
}
/* Setting date */
memcpy(tmpbuf, iter, 8);
tmpbuf[8] = 0;
@ -950,9 +955,12 @@ int parse_dan_format(const char *filename, char **params, int pnr)
}
if (ptr)
ptr = strstr(ptr, NL);
if (ptr)
if (ptr) {
ptr += strlen(NL);
} else {
fprintf(stderr, "DEBUG: Data corrupt");
return -1;
}
end_ptr = ptr - (char *)mem.buffer;
/* Copy the current dive data to start of mem_csv buffer */