aboutsummaryrefslogtreecommitdiff
path: root/lundump.c
diff options
context:
space:
mode:
Diffstat (limited to 'lundump.c')
-rw-r--r--lundump.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lundump.c b/lundump.c
index 74839af8..3b61cc8c 100644
--- a/lundump.c
+++ b/lundump.c
@@ -147,20 +147,20 @@ static void loadString (LoadState *S, Proto *p, TString **sl) {
147 TString *ts; 147 TString *ts;
148 TValue sv; 148 TValue sv;
149 size_t size = loadSize(S); 149 size_t size = loadSize(S);
150 if (size == 0) { /* no string? */ 150 if (size == 0) { /* previously saved string? */
151 lua_assert(*sl == NULL); /* must be prefilled */
152 return;
153 }
154 else if (size == 1) { /* previously saved string? */
155 lua_Unsigned idx = loadVarint(S, LUA_MAXUNSIGNED); /* get its index */ 151 lua_Unsigned idx = loadVarint(S, LUA_MAXUNSIGNED); /* get its index */
156 TValue stv; 152 TValue stv;
153 if (idx == 0) { /* no string? */
154 lua_assert(*sl == NULL); /* must be prefilled */
155 return;
156 }
157 if (novariant(luaH_getint(S->h, l_castU2S(idx), &stv)) != LUA_TSTRING) 157 if (novariant(luaH_getint(S->h, l_castU2S(idx), &stv)) != LUA_TSTRING)
158 error(S, "invalid string index"); 158 error(S, "invalid string index");
159 *sl = ts = tsvalue(&stv); /* get its value */ 159 *sl = ts = tsvalue(&stv); /* get its value */
160 luaC_objbarrier(L, p, ts); 160 luaC_objbarrier(L, p, ts);
161 return; /* do not save it again */ 161 return; /* do not save it again */
162 } 162 }
163 else if ((size -= 2) <= LUAI_MAXSHORTLEN) { /* short string? */ 163 else if ((size -= 1) <= LUAI_MAXSHORTLEN) { /* short string? */
164 char buff[LUAI_MAXSHORTLEN + 1]; /* extra space for '\0' */ 164 char buff[LUAI_MAXSHORTLEN + 1]; /* extra space for '\0' */
165 loadVector(S, buff, size + 1); /* load string into buffer */ 165 loadVector(S, buff, size + 1); /* load string into buffer */
166 *sl = ts = luaS_newlstr(L, buff, size); /* create string */ 166 *sl = ts = luaS_newlstr(L, buff, size); /* create string */