json: fix pointer arithmetic error
James Prestwood
PATCH 1/1 json: fix pointer arithmetic error
Subtracting the pointers is sufficient for counting the tokens, they do not need to be modulus the size of jsmntok_t
--- src/json.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/json.c +2 -2
@@ -82,7 +82,7 @@ static int find_object_tokens(struct json_iter *iter, jsmntok_t *object)if (!next) next =ITER_END (iter); -return ((next - object) %sizeof (jsmntok_t)) -1 ; +return next - object -1 ; } static void iter_recurse(struct json_iter *iter, jsmntok_t *object,
@@ -91,7 +91,7 @@ static void iter_recurse(struct json_iter *iter, jsmntok_t *object,struct json_contents *c = iter->contents; child->contents = c; - child->start = (object - c->tokens) %sizeof (jsmntok_t); + child->start = object - c->tokens; child->count =find_object_tokens (iter, object); }
Signature · 1 line
2.31.1
Denis Kenzior
AppliedHi James,
Quoted 6 lines · James Prestwood
Subtracting the pointers is sufficient for counting the tokens, they do not need to be modulus the size of
jsmntok_t--- src/json.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied, thanks.
Regards,
-Denis