Commit 35bac3c
authored
bugfix: fix truncation of decoded numbers outside lua_Integer's range (#116)
json_next_number_token stores the `long long` return value from `stroll`
in a `lua_Integer` (which is typically a typedef for `ptrdiff_t`).
On 32-bit platforms, this ends up storing an 8-byte number into a 4-byte
variable, truncating the value.
Instead, store the converted value in a temporary `long long` variable
so we can detect the scenario and decode into a `lua_Number`.
Signed-off-by: James McCoy <jamessan@jamessan.com>1 parent cd944c1 commit 35bac3c
1 file changed
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1190 | 1190 | | |
1191 | 1191 | | |
1192 | 1192 | | |
1193 | | - | |
| 1193 | + | |
1194 | 1194 | | |
1195 | 1195 | | |
1196 | 1196 | | |
| |||
1199 | 1199 | | |
1200 | 1200 | | |
1201 | 1201 | | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
1202 | 1209 | | |
1203 | 1210 | | |
| 1211 | + | |
1204 | 1212 | | |
1205 | 1213 | | |
1206 | 1214 | | |
| |||
0 commit comments