Check for trailing garbage inside json#80
Conversation
LB--
left a comment
There was a problem hiding this comment.
There are too many formatting/spacing changes that make it difficult to see the actual changed code. Would you be willing to try again without reformatting the source file?
|
@tmegow Could you perhaps discard the indentation and formatting commits? Then, commit Allow for empty objects and empty arrays must be reworked to only bring essential changes. I'm not saying the current format is perfect, but reformatting everything while adding actual changes is never an option. |
|
|
||
| void json_value_free (json_value *); | ||
|
|
||
| int trailing_garbage (const json_char *); |
There was a problem hiding this comment.
Does this function need to be declared in json.h? I don't think so, it should be a static function of json.c.
| case '"': | ||
| return 0; | ||
|
|
||
| case 'e': |
There was a problem hiding this comment.
It looks like you're looking for "false" Perhaps a strncmp() would be more readable. At least add a comment, like /* skipping "false" */ or something similar.
There was a problem hiding this comment.
But then would strncmp() work for all possible types of json_char?
| marker = *(--ptr); | ||
| if (marker == 's') | ||
| { | ||
| if (*(--ptr) == 'l' && *(--ptr) == 'a' && *(--ptr) == 'f') |
There was a problem hiding this comment.
Here you decrement --ptr multiple times. Are there cases where you could decrement past the beginning of the buffer?
| return 0; | ||
| } | ||
| } | ||
| if (marker == 'u') |
There was a problem hiding this comment.
It looks like you're looking for "true" Perhaps a strncmp() would be more readable. At least add a comment, like /* skipping "true" */ or something similar.
| } | ||
| if (marker == 'u') | ||
| { | ||
| if (*(--ptr) == 'r' && *(--ptr) == 't') |
There was a problem hiding this comment.
Same comment about multiple --ptr.
|
|
||
| return 1; | ||
|
|
||
| case 'l': |
There was a problem hiding this comment.
It looks like you're looking for "null" Perhaps a strncmp() would be more readable. At least add a comment, like /* skipping "null" */ or something similar.
| return 1; | ||
|
|
||
| case 'l': | ||
| if (*(--ptr) == 'l' && *(--ptr) == 'u' && *(--ptr) == 'n') |
There was a problem hiding this comment.
Same comment about multiple --ptr.
A stab at addressing open issue #73