zserge / jsmn

Jsmn is a world fastest JSON parser/tokenizer. This is the official repo replacing the old one at Bitbucket
MIT License
3.72k stars 783 forks source link

Boundary parsing bug in non-strict mode #106

Open ivarref opened 7 years ago

ivarref commented 7 years ago

Hi, and thanks for a fine library.

I believe I've found a boundary parsing bug in non-strict mode.

Steps to reproduce:

curl https://raw.githubusercontent.com/ivarref/jsmn/master/bad.json -o bad.json
gcc -DJSMN_STRICT=true ./example/jsondump.c ./jsmn.c -o ./strict
gcc ./example/jsondump.c ./jsmn.c -o ./loose

cat ./bad.json | ./strict > strict-output.txt
cat ./bad.json | ./loose > loose-output.txt

strict-output.txt and loose-output.txt should be identical, but they are not:

$ diff strict-output.txt loose-output.txt

27602c27602,27603
<          - 7777.0
---
>          - 7777.
>          - 0

Please let me know if I'm mistaken. Thanks for your reply and work on the library.