mirror of
https://github.com/janet-lang/janet
synced 2024-12-01 04:19:55 +00:00
Fix unmarshalling integers directly, not through readint.
This commit is contained in:
parent
4d96ba3ba9
commit
bdf03b4706
@ -564,10 +564,10 @@ static int32_t readint(UnmarshalState *st, const uint8_t **atdata) {
|
||||
data += 2;
|
||||
} else if (*data == LB_INTEGER) {
|
||||
if (data + 5 > st->end) longjmp(st->err, UMR_EOS);
|
||||
ret = (data[1] << 24) |
|
||||
(data[2] << 16) |
|
||||
(data[3] << 8) |
|
||||
data[4];
|
||||
ret = ((int32_t)(data[1]) << 24) |
|
||||
((int32_t)(data[2]) << 16) |
|
||||
((int32_t)(data[3]) << 8) |
|
||||
(int32_t)(data[4]);
|
||||
data += 5;
|
||||
} else {
|
||||
longjmp(st->err, UMR_EXPECTED_INTEGER);
|
||||
@ -939,10 +939,10 @@ static const uint8_t *unmarshal_one(
|
||||
/* Long integer */
|
||||
EXTRA(5);
|
||||
*out = janet_wrap_integer(
|
||||
(data[1]) |
|
||||
(data[2] << 8) |
|
||||
(data[3] << 16) |
|
||||
(data[4] << 24));
|
||||
(data[4]) |
|
||||
(data[3] << 8) |
|
||||
(data[2] << 16) |
|
||||
(data[1] << 24));
|
||||
return data + 5;
|
||||
case LB_REAL:
|
||||
/* Real */
|
||||
|
@ -154,6 +154,10 @@
|
||||
(testmarsh 1 "marshal small integers")
|
||||
(testmarsh -1 "marshal integers (-1)")
|
||||
(testmarsh 199 "marshal small integers (199)")
|
||||
(testmarsh 5000 "marshal medium integers (5000)")
|
||||
(testmarsh -5000 "marshal small integers (-5000)")
|
||||
(testmarsh 10000 "marshal large integers (10000)")
|
||||
(testmarsh -10000 "marshal large integers (-10000)")
|
||||
(testmarsh 1.0 "marshal double")
|
||||
(testmarsh "doctordolittle" "marshal string")
|
||||
(testmarsh :chickenshwarma "marshal symbol")
|
||||
|
Loading…
Reference in New Issue
Block a user