@@ -528,7 +528,7 @@ int map_create_array(var_p_t dest, JsonTokens *json, int end_position, int index
528528 list .head = NULL ;
529529 list .tail = NULL ;
530530
531- while (i < json -> num_tokens ) {
531+ while (i < json -> num_tokens && ! prog_error ) {
532532 jsmntok_t token = json -> tokens [i ];
533533 if (token .start > end_position ) {
534534 break ;
@@ -545,7 +545,7 @@ int map_create_array(var_p_t dest, JsonTokens *json, int end_position, int index
545545 cols = curcol ;
546546 }
547547 }
548- while (delim != NULL ) {
548+ while (delim != NULL && ! prog_error ) {
549549 rows ++ ;
550550 curcol = 0 ;
551551 len -= (delim - str ) + 1 ;
@@ -583,7 +583,7 @@ int map_create_array(var_p_t dest, JsonTokens *json, int end_position, int index
583583int map_create (var_p_t dest , JsonTokens * json , int end_position , int index ) {
584584 hashmap_create (dest , 0 );
585585 int i = index ;
586- while (i < json -> num_tokens ) {
586+ while (i < json -> num_tokens && ! prog_error ) {
587587 jsmntok_t token = json -> tokens [i ];
588588 if (token .start > end_position ) {
589589 break ;
@@ -593,7 +593,12 @@ int map_create(var_p_t dest, JsonTokens *json, int end_position, int index) {
593593 var_p_t value = hashmap_putv (dest , key );
594594 i = map_read_next_token (value , json , i + 1 );
595595 } else {
596- err_array ();
596+ int position = token .start ;
597+ if (i > 0 ) {
598+ // error near end of previous token
599+ position = json -> tokens [i - 1 ].start ;
600+ }
601+ err_json (position );
597602 break ;
598603 }
599604 }
0 commit comments