file.write_bytes fix

This commit is contained in:
Onran
2024-02-27 10:45:38 +09:00
committed by GitHub
parent a75d578aea
commit f2dff183f6
+1 -5
View File
@@ -140,11 +140,10 @@ int l_file_write_bytes(lua_State* L) {
int i = 1;
while(lua_next(L, bytesIndex) != 0) {
if(i == len) {
if(i >= len) {
break;
}
if(lua_isnumber(L, -1)) {
const int byte = lua_tointeger(L, -1);
if(byte < 0 || byte > 255) {
@@ -156,9 +155,6 @@ int l_file_write_bytes(lua_State* L) {
lua_pop(L, 1);
i++;
} else {
return luaL_error(L, "number expected at index '%i' (got %s)", i, lua_typename(L, lua_type(L, -1)));
}
}
lua_pushboolean(L, files::write_bytes(path, &bytes[0], len));