fix swprintf handling of nul character in output
[musl] / src / stdio / freopen.c
index 7ae116d..1641a4c 100644 (file)
@@ -1,4 +1,6 @@
 #include "stdio_impl.h"
+#include <fcntl.h>
+#include <unistd.h>
 
 /* The basic idea of this implementation is to open a new FILE,
  * hack the necessary parts of the new FILE into the old one, then
@@ -8,8 +10,6 @@
  * lock, via flockfile or otherwise, when freopen is called, and in that
  * case, freopen cannot act until the lock is released. */
 
-int __dup3(int, int, int);
-
 FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *restrict f)
 {
        int fl = __fmodeflags(mode);
@@ -40,6 +40,8 @@ FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *re
                fclose(f2);
        }
 
+       f->mode = 0;
+       f->locale = 0;
        FUNLOCK(f);
        return f;
 
@@ -49,5 +51,3 @@ fail:
        fclose(f);
        return NULL;
 }
-
-LFS64(freopen);