rewrite popen to use posix_spawn instead of fragile vfork hacks
[musl] / src / stdio / vswscanf.c
index 4396d7d..7a2f7c7 100644 (file)
@@ -1,4 +1,5 @@
 #include "stdio_impl.h"
+#include <wchar.h>
 
 static size_t wstring_read(FILE *f, unsigned char *buf, size_t len)
 {
@@ -17,13 +18,13 @@ static size_t wstring_read(FILE *f, unsigned char *buf, size_t len)
        f->rend = f->buf + k;
        f->cookie = (void *)src;
 
-       if (!len) return 0;
+       if (!len || !k) return 0;
 
        *buf = *f->rpos++;
        return 1;
 }
 
-int vswscanf(const wchar_t *s, const wchar_t *fmt, va_list ap)
+int vswscanf(const wchar_t *restrict s, const wchar_t *restrict fmt, va_list ap)
 {
        unsigned char buf[256];
        FILE f = {