From 75ea9ccbea7c4886f30da147fb67b693b2624c26 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 18 Aug 2020 14:48:43 -0300 Subject: 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 also fixes the identation in 'l_alloc'.) --- lauxlib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lauxlib.c') 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) { } else { /* cannot fail when shrinking a block */ void *newptr = realloc(ptr, nsize); - if (newptr == NULL && ptr != NULL && nsize <= osize) - return ptr; /* keep the original block */ - else /* no fail or not shrinking */ - return newptr; /* use the new block */ + if (newptr == NULL && ptr != NULL && nsize <= osize) + return ptr; /* keep the original block */ + else /* no fail or not shrinking */ + return newptr; /* use the new block */ } } -- cgit v1.2.3-55-g6feb