diff options
author | dequis <dx@dxzone.com.ar> | 2015-12-17 13:56:25 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2015-12-17 13:56:25 -0300 |
commit | ea39049f995fb01987a3556520639fefb3bb79a7 (patch) | |
tree | e0e1ca5480e6c38d3c4e19f0a61cddc38c4ca77c /lib/ini.c | |
parent | d11ccbf6ea94264bde8b0f525c4bbedf50de0174 (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/ini.c')
-rw-r--r-- | lib/ini.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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)) && |