static cJSON_bool parse_string(cJSON const item, parse_buffer const input_buffer)
{
...
// this does not work
if ((size_t)(input_end + 1 - input_buffer->content) >= input_buffer->length)
{
/ prevent buffer overflow when last input character is a backslash /
goto fail;
}
...
}
As show above , when last input character is a backslash.The index of input_end is always input_buffer->length - 2.
So input_end + 1 - input_buffer->content >= input_buffer->length will never come true。
Maybe we should minus 1 in the right:
input_end + 1 - input_buffer->content >= input_buffer->length-1
static cJSON_bool parse_string(cJSON const item, parse_buffer const input_buffer) { ... // this does not work if ((size_t)(input_end + 1 - input_buffer->content) >= input_buffer->length) { / prevent buffer overflow when last input character is a backslash / goto fail; } ... }
As show above , when last input character is a backslash.The index of input_end is always input_buffer->length - 2. So input_end + 1 - input_buffer->content >= input_buffer->length will never come true。
Maybe we should minus 1 in the right: input_end + 1 - input_buffer->content >= input_buffer->length-1