I don't see why the workaround must be in freopen-safer.c. freopen-safer has freopen as a prerequisite, so it can assume that freopen doesn't have the bug in question.

+#ifdef __KLIBC__
+  FILE *result = freopen (filename, mode, stream);
+
+  /* On OS/2 kLIBC, freopen() returns NULL even if it is successful
+     if filename is NULL. */
+  if (!result && !errno)
+    result = stream;
+
+  return result;
+#else
   return freopen (filename, mode, stream);
+#endif

This should be refactored so that there's only one call to freopen, to avoid duplicating the code.

Reply via email to