netcdf-c icon indicating copy to clipboard operation
netcdf-c copied to clipboard

Avoid segfault if opening file failed

Open rouault opened this issue 3 years ago • 0 comments

It looks like on some platforms (e.g., MinGW) errno isn't set when opening a file failed. That combination of a file id <0 and errno still 0 leads to a segmentation fault later on.

A possible solution to avoid that segfault is to set the status to ENOENT if errno is unexpectedly 0. That leads to the error ("No such file or directory") that was reportedly emitted before version 4.9.0.

See also this report downstream: https://github.com/msys2/MINGW-packages/issues/11918

rouault avatar Jun 23 '22 19:06 rouault