Commit d8c6a552 authored by Andreas Schuh's avatar Andreas Schuh

Fix bug in SafeFOpen showing up in Cygwin. Errno only guaranteed to be set on failure.

parent b18fe77e
...@@ -364,7 +364,8 @@ inline int SafeFOpen(FILE **fp, const char* fname, const char *mode) ...@@ -364,7 +364,8 @@ inline int SafeFOpen(FILE **fp, const char* fname, const char *mode)
#else #else
assert(fp != NULL); assert(fp != NULL);
*fp = fopen(fname, mode); *fp = fopen(fname, mode);
return errno; // errno only guaranteed to be set on failure
return ((*fp == NULL) ? errno : 0);
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment