about summary refs log tree commit diff
path: root/src/stdio/vfwscanf.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-07-20 00:21:11 -0400
committerRich Felker <dalias@aerifal.cx>2013-07-20 00:21:11 -0400
commit1d92cddb1e1ed4b6cc0e55461727561e7a2522e0 (patch)
treed4f7a600da055639ac71aa28463d862d04fc91d7 /src/stdio/vfwscanf.c
parent8389520ed5ad6f0033d6426e21ef653fa5ca26a4 (diff)
downloadmusl-1d92cddb1e1ed4b6cc0e55461727561e7a2522e0.tar.gz
musl-1d92cddb1e1ed4b6cc0e55461727561e7a2522e0.tar.xz
musl-1d92cddb1e1ed4b6cc0e55461727561e7a2522e0.zip
fix uninitialized/stale use of alloc (%m modifier) flag in scanf
for conversion specifiers, alloc is always set when the specifier is
parsed. however, if scanf stops due to mismatching literal text,
either an uninitialized (if no conversions have been performed yet) or
stale (from the previous conversion) of the flag will be used,
possibly causing an invalid pointer to be passed to free when the
function returns.
Diffstat (limited to 'src/stdio/vfwscanf.c')
-rw-r--r--src/stdio/vfwscanf.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/stdio/vfwscanf.c b/src/stdio/vfwscanf.c
index 760864ff..44fac78e 100644
--- a/src/stdio/vfwscanf.c
+++ b/src/stdio/vfwscanf.c
@@ -109,6 +109,8 @@ int vfwscanf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap)
 
 	for (p=fmt; *p; p++) {
 
+		alloc = 0;
+
 		if (iswspace(*p)) {
 			while (iswspace(p[1])) p++;
 			while (iswspace((c=getwc(f)))) pos++;