--- -/lib/libc/stdio/vfwscanf.c
+++ +/lib/libc/stdio/vfwscanf.c
@@ -268,15 +268,13 @@
 
 		case '[':
 			ccls = fmt;
-			if (*fmt == '^') {
-				cclcompl = 1;
-				fmt++;
-			} else
-				cclcompl = 0;
+			cclcompl = (*fmt == '^');
+			fmt += cclcompl;
 			if (*fmt == ']')
 				fmt++;
-			while (*fmt != '\0' && *fmt != ']')
-				fmt++;
+			while (*fmt != ']')
+				if (*fmt++ == '\0')
+					goto input_failure;
 			ccle = fmt;
 			fmt++;
 			flags |= NOSKIP;
