Length of external strings must fit in Lua integer

(As the length of any string in Lua.)
This commit is contained in:
Roberto Ierusalimschy
2024-06-24 12:03:59 -03:00
parent 0f7025dcae
commit c1dc08e8e8
4 changed files with 9 additions and 4 deletions

1
lapi.c
View File

@@ -551,6 +551,7 @@ LUA_API const char *lua_pushextlstring (lua_State *L,
const char *s, size_t len, lua_Alloc falloc, void *ud) {
TString *ts;
lua_lock(L);
api_check(L, len <= MAX_SIZE, "string too large");
api_check(L, s[len] == '\0', "string not ending with zero");
ts = luaS_newextlstr (L, s, len, falloc, ud);
setsvalue2s(L, L->top.p, ts);