aboutsummaryrefslogtreecommitdiff
path: root/lundump.c
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 /lundump.c
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 'lundump.c')
-rw-r--r--lundump.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lundump.c b/lundump.c
index cb124d6f..5aa55c44 100644
--- a/lundump.c
+++ b/lundump.c
@@ -120,7 +120,10 @@ static TString *loadStringN (LoadState *S, Proto *p) {
120 } 120 }
121 else { /* long string */ 121 else { /* long string */
122 ts = luaS_createlngstrobj(L, size); /* create string */ 122 ts = luaS_createlngstrobj(L, size); /* create string */
123 setsvalue2s(L, L->top, ts); /* anchor it ('loadVector' can GC) */
124 luaD_inctop(L);
123 loadVector(S, getstr(ts), size); /* load directly in final place */ 125 loadVector(S, getstr(ts), size); /* load directly in final place */
126 L->top--; /* pop string */
124 } 127 }
125 luaC_objbarrier(L, p, ts); 128 luaC_objbarrier(L, p, ts);
126 return ts; 129 return ts;