bignerdranch / Freddy

A reusable framework for parsing JSON in Swift.
MIT License
1.09k stars 120 forks source link

Do not crash when string ends in backslash #216

Closed pbardea closed 7 years ago

pbardea commented 7 years ago

The problem was that the parser would read beyond a backslash even if it was the last character, so rather than reporting it as invalid JSON and throwing an error it would try to read beyond the string and crash. This fix just adds a check to ensure that the parser doesn't read out of bounds.

Also added a test to handle this case.

I'm still not very familiar with the code base, so if there are any styles nits, or any other feedback I'd be grateful!

pbardea commented 7 years ago

Addresses #206

jgallagher commented 7 years ago

Thanks! Sorry for the long delay.