compuphase / minIni

A small and portable INI file library with read/write support
http://www.compuphase.com/minini.htm
Other
371 stars 113 forks source link

Leaking file descriptors #18

Closed Jan200101 closed 2 years ago

Jan200101 commented 2 years ago

https://github.com/compuphase/minIni/blob/51d636f9c60f8d013860965565b447ef14dc2286/dev/minGlue-Linux.h#L23-L25 the file descriptor returned by the first fopen ends up being leaked

compuphase commented 2 years ago

The && operator is "short circuit" in C. In the expression "A && B", B is only evaluated if A is true. If A is false, B is entirely skipped. In this case, A is true when "fopen((filename), "r+") == NULL". So the second call to fopen (line 25) only happens if the first fopen fails. Hence, there is no leak.