I really don't think that there is a memory leak
The scope of the variable is local (though inline).
All instances of the local variable
are automatically deallocated at the end of the program.
Whenever you use the functions fopen / open etc, it needn't be that
they return the right result. There is also
a limit on the number of Open files at a point of Time (in DOS...)
And a file can't be opened in rw mode if it's read-only.
So, it is better really to use lower level functions that
handle with the OS.
maybe stat() is one such thing. Or
try to get the status of a dir system command ...
There are reommended possible ways of doing the file checking.