Changeset ea39049


Ignore:
Timestamp:
2015-12-17T16:56:25Z (8 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
f66425d
Parents:
d11ccbf
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/ini.c

    rd11ccbf rea39049  
    2828ini_t *ini_open(char *file)
    2929{
    30         int fd;
     30        int fd = -1;
    3131        ini_t *ini = NULL;
    3232        struct stat fi;
    3333
    34         if ((fd = open(file, O_RDONLY)) != -1 &&
     34        if (file && (fd = open(file, O_RDONLY)) != -1 &&
    3535            fstat(fd, &fi) == 0 &&
    3636            fi.st_size <= 16384 &&
Note: See TracChangeset for help on using the changeset viewer.