summaryrefslogtreecommitdiff
path: root/libs/liblua/src/lundump.c
diff options
context:
space:
mode:
authordartraiden <wowemuh@gmail.com>2020-10-11 16:04:04 +0300
committerdartraiden <wowemuh@gmail.com>2020-10-11 16:04:25 +0300
commit20c5f9b5ad74780ec2cade5a47bd066ed69453b0 (patch)
treec958fc5005d0bf5a0fa782a8696a14c6eaaa1c46 /libs/liblua/src/lundump.c
parent540874feb0fefb5610fb96e1a5462b500265f90b (diff)
liblua: update to 5.4.1
Diffstat (limited to 'libs/liblua/src/lundump.c')
-rw-r--r--libs/liblua/src/lundump.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/libs/liblua/src/lundump.c b/libs/liblua/src/lundump.c
index 4243678a72..5aa55c4457 100644
--- a/libs/liblua/src/lundump.c
+++ b/libs/liblua/src/lundump.c
@@ -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;
@@ -200,13 +203,20 @@ static void loadProtos (LoadState *S, Proto *f) {
}
+/*
+** Load the upvalues for a function. The names must be filled first,
+** because the filling of the other fields can raise read errors and
+** the creation of the error message can call an emergency collection;
+** in that case all prototypes must be consistent for the GC.
+*/
static void loadUpvalues (LoadState *S, Proto *f) {
int i, n;
n = loadInt(S);
f->upvalues = luaM_newvectorchecked(S->L, n, Upvaldesc);
f->sizeupvalues = n;
- for (i = 0; i < n; i++) {
+ for (i = 0; i < n; i++) /* make array valid for GC */
f->upvalues[i].name = NULL;
+ for (i = 0; i < n; i++) { /* following calls can raise errors */
f->upvalues[i].instack = loadByte(S);
f->upvalues[i].idx = loadByte(S);
f->upvalues[i].kind = loadByte(S);