summaryrefslogtreecommitdiffstats
path: root/libdivecomputer.c
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2014-01-07 16:41:20 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-08 05:53:05 +0800
commit4d8168cc5793d5dfc2b263b5700f8fe5088c9cf4 (patch)
tree9ee1b9b31680c8c19b7b29efcd00777e943769a5 /libdivecomputer.c
parent3c794d0275235bc631435285aa6da20c639ffeaa (diff)
downloadsubsurface-4d8168cc5793d5dfc2b263b5700f8fe5088c9cf4.tar.gz
libdivecomputer.c: Try not to pass NULL to fopen()
C99 7.1.4, says nothing about passing NULL to fopen(), which means that it isn't portable and there are no guaranties that the return will be a NULL pointer or that that a library implementation will not assert or SYSSEGV in the middle of the fopen() branch. libdivecomputer.c's 'dumpfile_name' and 'logfile_name' could cause problems in that regard. A possible fix for #411 Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'libdivecomputer.c')
-rw-r--r--libdivecomputer.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c
index 105a08133..78d3808f9 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -676,7 +676,7 @@ static const char *do_device_import(device_data_t *data)
dc_buffer_t *buffer = dc_buffer_new (0);
rc = dc_device_dump (device, buffer);
- if (rc == DC_STATUS_SUCCESS) {
+ if (rc == DC_STATUS_SUCCESS && dumpfile_name) {
FILE* fp = subsurface_fopen(dumpfile_name, "wb");
if (fp != NULL) {
fwrite (dc_buffer_get_data (buffer), 1, dc_buffer_get_size (buffer), fp);
@@ -721,7 +721,7 @@ const char *do_libdivecomputer_import(device_data_t *data)
data->device = NULL;
data->context = NULL;
- if (data->libdc_log)
+ if (data->libdc_log && logfile_name)
fp = subsurface_fopen(logfile_name, "w");
rc = dc_context_new(&data->context);