File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,13 @@ public JSONArray(JSONTokener x) throws JSONException {
107
107
if (x .nextClean () != '[' ) {
108
108
throw x .syntaxError ("A JSONArray text must start with '['" );
109
109
}
110
- if (x .nextClean () != ']' ) {
110
+
111
+ char nextChar = x .nextClean ();
112
+ if (nextChar == 0 ) {
113
+ // array is unclosed. No ']' found, instead EOF
114
+ throw new JSONException (x .syntaxError ("Expected a ',' or ']'" ));
115
+ }
116
+ if (nextChar != ']' ) {
111
117
x .back ();
112
118
for (;;) {
113
119
if (x .nextClean () == ',' ) {
@@ -118,8 +124,16 @@ public JSONArray(JSONTokener x) throws JSONException {
118
124
this .myArrayList .add (x .nextValue ());
119
125
}
120
126
switch (x .nextClean ()) {
127
+ case 0 :
128
+ // array is unclosed. No ']' found, instead EOF
129
+ throw new JSONException (x .syntaxError ("Expected a ',' or ']'" ));
121
130
case ',' :
122
- if (x .nextClean () == ']' ) {
131
+ nextChar = x .nextClean ();
132
+ if (nextChar == 0 ) {
133
+ // array is unclosed. No ']' found, instead EOF
134
+ throw new JSONException (x .syntaxError ("Expected a ',' or ']'" ));
135
+ }
136
+ if (nextChar == ']' ) {
123
137
return ;
124
138
}
125
139
x .back ();
You can’t perform that action at this time.
0 commit comments