diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-12-27 22:11:00 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-12-27 22:13:31 -0800 |
commit | 6cc5b601aa36a7ede89ab13274cb334aa92f5cf7 (patch) | |
tree | df0370674c273546d53706f8f6042ecb83a57821 /core | |
parent | e8719413a7962f737938a59ce54637352fb282f4 (diff) | |
download | subsurface-6cc5b601aa36a7ede89ab13274cb334aa92f5cf7.tar.gz |
Cleanup: avoid dereferencing NULL pointer
Coverity CID 208330
Coverity CID 208301
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/file.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/core/file.c b/core/file.c index e818c9e21..d604f94cd 100644 --- a/core/file.c +++ b/core/file.c @@ -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 */ |