mirror of
https://github.com/lua/lua.git
synced 2026-10-26 10:35:26 +00:00
Correction of maximum string size in 'lundump'
The maximum size for internal strings in Lua is MAX_SIZE minus 'sizeof(TString)'. Moreover, 'loadVarint' must be precise about the limit of the integer being read.
This commit is contained in:
@@ -303,6 +303,7 @@ checkI(function () return 0xF0.0 | 0xCC.0 ~ 0xAA & 0xFD end, 0xF4)
|
||||
checkI(function () return ~(~kFF0 | kFF0) end, 0)
|
||||
checkI(function () return ~~-1024.0 end, -1024)
|
||||
checkI(function () return ((100 << k6) << -4) >> 2 end, 100)
|
||||
checkK(function () return ~(-1 >> 1) end, math.mininteger)
|
||||
|
||||
-- borders around MAXARG_sBx ((((1 << 17) - 1) >> 1) == 65535)
|
||||
local a = 17; local sbx = ((1 << a) - 1) >> 1 -- avoid folding
|
||||
|
||||
@@ -385,6 +385,12 @@ do
|
||||
assert(minint == load("return " .. minint)())
|
||||
assert(eqT(maxint, load("return " .. maxint)()))
|
||||
|
||||
-- limit for integer encoding in binary chunks
|
||||
-- (~(-1 >> 1) is optimized by the compiler as minint, which is
|
||||
-- then encoded in a binary chunk as max unsigned)
|
||||
local f = string.dump(function () return ~(-1 >> 1) end)
|
||||
assert(load(f)() == minint)
|
||||
|
||||
assert(eqT(10000000000000000000000.0, 10000000000000000000000))
|
||||
assert(eqT(-10000000000000000000000.0, -10000000000000000000000))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user