File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -1037,8 +1037,11 @@ char *
10371037json_format_string (const char * text )
10381038{
10391039 size_t pos = 0 , text_length ;
1040- unsigned int indentation = 0 ; /* the current indentation level */
1041- unsigned int i ; /* loop iterator variable */
1040+
1041+ // make sure these two integers are signed
1042+ // we want to allow negative when the json is bad
1043+ signed int indentation = 0 ; /* the current indentation level */
1044+ signed int i ; /* loop iterator variable */
10421045 char loop ;
10431046
10441047 rcstring * output ;
@@ -1069,6 +1072,9 @@ json_format_string (const char *text)
10691072 case '}' :
10701073 indentation -- ;
10711074 rcs_catc (output , '\n' );
1075+ // the for loop will compare i with potential negative values
1076+ // so we don't get caught in an infinite loop if the json is faulty with more "}" than "{"
1077+ // we just print out the same number of faulty "}" characters.
10721078 for (i = 0 ; i < indentation ; i ++ )
10731079 {
10741080 rcs_catc (output , '\t' );
You can’t perform that action at this time.
0 commit comments