aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-08-18 14:42:11 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-08-18 14:42:11 -0300
commit6bc0f13505bf5d4f613d725fe008c79e72f83ddf (patch)
tree80d36907c5d8b030ba7928d6ac30ac953cece612 /testes
parent8a89da07baf43f0dea4b06a7b2780302d75cb61c (diff)
downloadlua-6bc0f13505bf5d4f613d725fe008c79e72f83ddf.tar.gz
lua-6bc0f13505bf5d4f613d725fe008c79e72f83ddf.tar.bz2
lua-6bc0f13505bf5d4f613d725fe008c79e72f83ddf.zip
Fixed bug of long strings in binary chunks
When "undumping" a long string, the function 'loadVector' can call the reader function, which can run the garbage collector, which can collect the string being read. So, the string must be anchored during the call to 'loadVector'.
Diffstat (limited to 'testes')
-rw-r--r--testes/calls.lua16
1 files changed, 15 insertions, 1 deletions
diff --git a/testes/calls.lua b/testes/calls.lua
index decf4176..ff72d8f6 100644
--- a/testes/calls.lua
+++ b/testes/calls.lua
@@ -317,6 +317,16 @@ f = load(string.dump(function () return 1 end), nil, "b", {})
317assert(type(f) == "function" and f() == 1) 317assert(type(f) == "function" and f() == 1)
318 318
319 319
320do -- another bug (in 5.4.0)
321 -- loading a binary long string interrupted by GC cycles
322 local f = string.dump(function ()
323 return '01234567890123456789012345678901234567890123456789'
324 end)
325 f = load(read1(f))
326 assert(f() == '01234567890123456789012345678901234567890123456789')
327end
328
329
320x = string.dump(load("x = 1; return x")) 330x = string.dump(load("x = 1; return x"))
321a = assert(load(read1(x), nil, "b")) 331a = assert(load(read1(x), nil, "b"))
322assert(a() == 1 and _G.x == 1) 332assert(a() == 1 and _G.x == 1)
@@ -358,8 +368,12 @@ x = [[
358 end 368 end
359 end 369 end
360]] 370]]
371a = assert(load(read1(x), "read", "t"))
372assert(a()(2)(3)(10) == 15)
361 373
362a = assert(load(read1(x))) 374-- repeat the test loading a binary chunk
375x = string.dump(a)
376a = assert(load(read1(x), "read", "b"))
363assert(a()(2)(3)(10) == 15) 377assert(a()(2)(3)(10) == 15)
364 378
365 379