aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-12-17 13:56:25 -0300
committerdequis <dx@dxzone.com.ar>2015-12-17 13:56:25 -0300
commitea39049f995fb01987a3556520639fefb3bb79a7 (patch)
treee0e1ca5480e6c38d3c4e19f0a61cddc38c4ca77c /lib
parentd11ccbf6ea94264bde8b0f525c4bbedf50de0174 (diff)
ini: Null check file parameter before passing it to open()
The test suite does this. It's harmless in practice but open() is declared as nonnull. Thanks to clang's ubsan.
Diffstat (limited to 'lib')
-rw-r--r--lib/ini.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ini.c b/lib/ini.c
index 4dbdec64..be2de974 100644
--- a/lib/ini.c
+++ b/lib/ini.c
@@ -27,11 +27,11 @@
ini_t *ini_open(char *file)
{
- int fd;
+ int fd = -1;
ini_t *ini = NULL;
struct stat fi;
- if ((fd = open(file, O_RDONLY)) != -1 &&
+ if (file && (fd = open(file, O_RDONLY)) != -1 &&
fstat(fd, &fi) == 0 &&
fi.st_size <= 16384 &&
(ini = g_malloc(sizeof(ini_t) + fi.st_size + 1)) &&