summaryrefslogtreecommitdiff
path: root/lauxlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-08-18 14:48:43 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-08-18 14:48:43 -0300
commit75ea9ccbea7c4886f30da147fb67b693b2624c26 (patch)
tree171be7ee405be5a3a64771116752c74111357a86 /lauxlib.c
parent5027298b46c1e436bc7a007554139a29f34c2971 (diff)
downloadlua-v5.3.tar.gz
lua-v5.3.tar.bz2
lua-v5.3.zip
Fixed bug of long strings in binary chunksv5.3.6v5.3
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 also fixes the identation in 'l_alloc'.)
Diffstat (limited to 'lauxlib.c')
-rw-r--r--lauxlib.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 097c3cf3..ac68bd32 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1013,10 +1013,10 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
1013 } 1013 }
1014 else { /* cannot fail when shrinking a block */ 1014 else { /* cannot fail when shrinking a block */
1015 void *newptr = realloc(ptr, nsize); 1015 void *newptr = realloc(ptr, nsize);
1016 if (newptr == NULL && ptr != NULL && nsize <= osize) 1016 if (newptr == NULL && ptr != NULL && nsize <= osize)
1017 return ptr; /* keep the original block */ 1017 return ptr; /* keep the original block */
1018 else /* no fail or not shrinking */ 1018 else /* no fail or not shrinking */
1019 return newptr; /* use the new block */ 1019 return newptr; /* use the new block */
1020 } 1020 }
1021} 1021}
1022 1022