about summary refs log tree commit diff
path: root/src/stdio/vfscanf.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-04-17 14:22:22 -0400
committerRich Felker <dalias@aerifal.cx>2012-04-17 14:22:22 -0400
commite0d9f780d171326a12bf9daf2af1e2f0c51c89f6 (patch)
treed3dfdfd39dfdac0daadd832a0d1f8782cc8914e8 /src/stdio/vfscanf.c
parent73ec1d0495bb676012fd69491900ca8beb989ef7 (diff)
downloadmusl-e0d9f780d171326a12bf9daf2af1e2f0c51c89f6.tar.gz
musl-e0d9f780d171326a12bf9daf2af1e2f0c51c89f6.tar.xz
musl-e0d9f780d171326a12bf9daf2af1e2f0c51c89f6.zip
fix some bugs in scanf %[ handling detected while writing the wide version
Diffstat (limited to 'src/stdio/vfscanf.c')
-rw-r--r--src/stdio/vfscanf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c
index 926d8a9d..8be0d91c 100644
--- a/src/stdio/vfscanf.c
+++ b/src/stdio/vfscanf.c
@@ -227,14 +227,14 @@ int vfscanf(FILE *f, const char *fmt, va_list ap)
 
 			scanset[0] = 0;
 			if (*p == '-') p++, scanset[1+'-'] = 1-invert;
-			if (*p == ']') p++, scanset[1+']'] = 1-invert;
-			for (; *p && *p != ']'; p++) {
-				if (*p=='-' && p[1] != ']')
+			else if (*p == ']') p++, scanset[1+']'] = 1-invert;
+			for (; *p != ']'; p++) {
+				if (!*p) goto fmt_fail;
+				if (*p=='-' && p[1] && p[1] != ']')
 					for (c=p++[-1]; c<*p; c++)
 						scanset[1+c] = 1-invert;
 				scanset[1+*p] = 1-invert;
 			}
-			if (!*p) goto fmt_fail;
 
 			if (size == SIZE_l) {
 				st = (mbstate_t){0};