Commits

Anonymous committed 555ce4f

Fix: check if no tokens lefs, return error in that case

Comments (0)

Files changed (1)

 			case '\t' : case '\r' : case '\n' : case ' ' :
 			case ','  : case ']'  : case '}' :
 				token = jsmn_get_token(parser);
+				if (token == NULL)
+					return JSMN_ERROR_NOMEM;
 				jsmn_fill_token(token, JSON_PRIMITIVE, start, parser->pos);
 				parser->pos--;
 				return JSMN_SUCCESS;
 		/* Quote: end of string */
 		if (c == '\"') {
 			token = jsmn_get_token(parser);
+			if (token == NULL)
+				return JSMN_ERROR_NOMEM;
 			jsmn_fill_token(token, JSON_PRIMITIVE, start+1, parser->pos);
 			return JSMN_SUCCESS;
 		}
 		switch (c) {
 			case '{': case '[':
 				token = jsmn_get_token(parser);
+				if (token == NULL)
+					return JSMN_ERROR_NOMEM;
 				token->type = (c == '{' ? JSON_OBJECT : JSON_ARRAY);
 				token->start = parser->pos;
 				break;