json-c/json-c — pull request #38 by pathorn (2012-07-17 04:49:20+00:00)
Title: Fix parser bug with invalid use of ERANGE

If a bad number is encountered, all numbers after it are set to INT_MAX
until some syscall resets errno, which may or may not happen.

This is caused by incorrect use of errno, which is unchanged if sscanf succeeds.
In glibc, sscanf succeeds for int64 values between 2^63 and 2^64-1 despite the number
being out of range. This causes the sanity check to fail.

The check for ERANGE was incorrect -- if sscanf succeeds, it cannot change errno.
Hence, the only place where ERANGE could be set is in the sanity check.