diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-03-13 15:30:52 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-03-13 15:30:52 -0300 |
commit | 22974326ca0d4f893849ce722cc1d65b3e228f42 (patch) | |
tree | 1b4cb2cad1c55edce63e9fe6e468b1833950397d /testes/events.lua | |
parent | c931d86e98da320c71da70c16d44aa28e9755520 (diff) | |
download | lua-22974326ca0d4f893849ce722cc1d65b3e228f42.tar.gz lua-22974326ca0d4f893849ce722cc1d65b3e228f42.tar.bz2 lua-22974326ca0d4f893849ce722cc1d65b3e228f42.zip |
Use after free in 'luaV_finishset'
If a metatable is a weak table, its __newindex field could be collected
by an emergency collection while being used in 'luaV_finishset'. (This
bug has similarities with bug 5.3.2-1, fixed in commit a272fa66.)
Diffstat (limited to '')
-rw-r--r-- | testes/events.lua | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/testes/events.lua b/testes/events.lua index 2500fbd5..7e434b1f 100644 --- a/testes/events.lua +++ b/testes/events.lua | |||
@@ -379,6 +379,17 @@ x = 0 .."a".."b"..c..d.."e".."f".."g" | |||
379 | assert(x.val == "0abcdefg") | 379 | assert(x.val == "0abcdefg") |
380 | 380 | ||
381 | 381 | ||
382 | do | ||
383 | -- bug since 5.4.1 (test needs T) | ||
384 | local mt = setmetatable({__newindex={}}, {__mode='v'}) | ||
385 | local t = setmetatable({}, mt) | ||
386 | |||
387 | if T then T.allocfailnext() end | ||
388 | |||
389 | -- seg. fault | ||
390 | for i=1, 10 do t[i] = 1 end | ||
391 | end | ||
392 | |||
382 | -- concat metamethod x numbers (bug in 5.1.1) | 393 | -- concat metamethod x numbers (bug in 5.1.1) |
383 | c = {} | 394 | c = {} |
384 | local x | 395 | local x |
@@ -481,7 +492,7 @@ assert(not pcall(function (a,b) return a[b] end, a, 10)) | |||
481 | assert(not pcall(function (a,b,c) a[b] = c end, a, 10, true)) | 492 | assert(not pcall(function (a,b,c) a[b] = c end, a, 10, true)) |
482 | 493 | ||
483 | -- bug in 5.1 | 494 | -- bug in 5.1 |
484 | T, K, V = nil | 495 | local T, K, V = nil |
485 | grandparent = {} | 496 | grandparent = {} |
486 | grandparent.__newindex = function(t,k,v) T=t; K=k; V=v end | 497 | grandparent.__newindex = function(t,k,v) T=t; K=k; V=v end |
487 | 498 | ||