file.write_bytes fix

This commit is contained in:
Onran
2024-03-03 15:11:52 +03:00
committed by MihailRis
parent 9c66d87699
commit ed1b660dcc
+1 -5
View File
@@ -140,11 +140,10 @@ int l_file_write_bytes(lua_State* L) {
int i = 1; int i = 1;
while(lua_next(L, bytesIndex) != 0) { while(lua_next(L, bytesIndex) != 0) {
if(i == len) { if(i >= len) {
break; break;
} }
if(lua_isnumber(L, -1)) {
const int byte = lua_tointeger(L, -1); const int byte = lua_tointeger(L, -1);
if(byte < 0 || byte > 255) { if(byte < 0 || byte > 255) {
@@ -156,9 +155,6 @@ int l_file_write_bytes(lua_State* L) {
lua_pop(L, 1); lua_pop(L, 1);
i++; 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)); lua_pushboolean(L, files::write_bytes(path, &bytes[0], len));