Skip to content

json: Fix a disjointed update of a token's pointer and length in json_deq() #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions json.h
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ json_deq(struct json_token *tok)
{
/* dequotes a string token */
if (tok->str[0] == '\"' && tok->len >= 2)
tok->str++; tok->len-=2;
tok->str++, tok->len-=2;
}
JSON_INTERN json_number
json_ipow(int base, unsigned exp)
Expand Down Expand Up @@ -851,7 +851,7 @@ JSON_API struct json_iter
json_begin(const char *str, int len)
{
struct json_iter iter = JSON_ITER_NULL;
iter.src = str; iter.len = len;
iter.src = str, iter.len = len;
return iter;
}
JSON_API struct json_iter
Expand Down Expand Up @@ -958,7 +958,7 @@ json_read(struct json_token *obj, const struct json_iter* prev)
iter.src = cur;
iter.len = len;
return iter;
} cur--; len++;
} cur--, len++;
} break;
case JSON_STATE_UTF8_2: {
iter.go = json_go_utf8;
Expand Down Expand Up @@ -1230,7 +1230,7 @@ json_query(struct json_token *toks, int count, const char *path)
array.len = 0;

/* iterate over each array element and find the correct index */
iter++; i++;
iter++, i++;
for (j = 0; j < n; ++j) {
if (iter->type == JSON_ARRAY || iter->type == JSON_OBJECT) {
i = i + (iter->sub) + 1;
Expand Down