mirror of
https://github.com/lua/lua
synced 2026-09-26 16:17:11 +03:00
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'.
This commit is contained in:
parent
8a89da07ba
commit
6bc0f13505
2 changed files with 18 additions and 1 deletions
|
|
@ -120,7 +120,10 @@ static TString *loadStringN (LoadState *S, Proto *p) {
|
|||
}
|
||||
else { /* long string */
|
||||
ts = luaS_createlngstrobj(L, size); /* create string */
|
||||
setsvalue2s(L, L->top, ts); /* anchor it ('loadVector' can GC) */
|
||||
luaD_inctop(L);
|
||||
loadVector(S, getstr(ts), size); /* load directly in final place */
|
||||
L->top--; /* pop string */
|
||||
}
|
||||
luaC_objbarrier(L, p, ts);
|
||||
return ts;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue