freopen: Don't crash if the filename argument is NULL.
authorClaudio Bley <claudio.bley@gmail.com>
Wed, 31 Aug 2011 08:12:25 +0000 (10:12 +0200)
committerIan Beckwith <ianb@erislabs.net>
Wed, 7 Sep 2011 23:48:48 +0000 (00:48 +0100)
* lib/freopen.c (rpl_freopen): Don't compare the filename if it is
NULL.
(cherry picked from commit a0d9972bfe5609bd225968ddfa76188ffa48280b)

ChangeLog
lib/freopen.c

index ee56aa9..d06bced 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-08-31  Claudio Bley  <claudio.bley@gmail.com>  (tiny change)
+
+       freopen: Don't crash if the filename argument is NULL.
+       * lib/freopen.c (rpl_freopen): Don't compare the filename if it is
+       NULL.
+
 2011-08-30  Paul Eggert  <eggert@cs.ucla.edu>
 
        openat: work around AIX 7.1 fstatat bug
index c763365..bae0646 100644 (file)
@@ -41,7 +41,7 @@ FILE *
 rpl_freopen (const char *filename, const char *mode, FILE *stream)
 {
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-  if (strcmp (filename, "/dev/null") == 0)
+  if (filename != NULL && strcmp (filename, "/dev/null") == 0)
     filename = "NUL";
 #endif