fix undefined behavior in wcsto[ld] family functions
[musl] / src / stdlib / wcstod.c
index 83f308d..0deb701 100644 (file)
@@ -1,6 +1,7 @@
 #include "shgetc.h"
 #include "floatscan.h"
 #include "stdio_impl.h"
+#include <wchar.h>
 #include <wctype.h>
 
 /* This read function heavily cheats. It knows:
@@ -32,8 +33,7 @@ static long double wcstox(const wchar_t *s, wchar_t **p, int prec)
        unsigned char buf[64];
        FILE f = {0};
        f.flags = 0;
-       f.rpos = f.rend = 0;
-       f.buf = buf + 4;
+       f.rpos = f.rend = f.buf = buf + 4;
        f.buf_size = sizeof buf - 4;
        f.lock = -1;
        f.read = do_read;