1
0
Fork 0
mirror of https://github.com/lua/lua.git synced 2025-07-04 04:04:06 +00:00

Loading a binary chunk should not break assertions

Although the execution of a bad binary chunk can crash the interpreter,
simply loading it should be safe.
This commit is contained in:
Roberto Ierusalimschy 2025-06-04 12:55:43 -03:00
parent 519c57d597
commit d05fe48bfd
2 changed files with 4 additions and 1 deletions

View file

@ -234,7 +234,7 @@ static void loadConstants (LoadState *S, Proto *f) {
f->source = NULL;
break;
}
default: lua_assert(0);
default: error(S, "invalid constant");
}
}
}

View file

@ -1402,6 +1402,9 @@ Chunks can also be precompiled into binary form;
see the program @idx{luac} and the function @Lid{string.dump} for details.
Programs in source and compiled forms are interchangeable;
Lua automatically detects the file type and acts accordingly @seeF{load}.
Be aware that, unlike source code,
the execution of maliciously crafted
bytecode can crash the interpreter.
}