gopher-lua
gopher-lua copied to clipboard
RawSet accepts nil keys
- [x] GopherLua is a Lua5.1 implementation. You should be familiar with Lua programming language. Have you read Lua 5.1 reference manual carefully?
- [x] GopherLua is a Lua5.1 implementation. In Lua, to keep it simple, it is more important to remove functionalities rather than to add functionalities unlike other languages . If you are going to introduce some new cool functionalities into the GopherLua code base and the functionalities can be implemented by existing APIs, It should be implemented as a library.
Please answer the following before submitting your issue:
- What version of GopherLua are you using? : ee81675732da
- What version of Go are you using? : 1.16
- What operating system and processor architecture are you using? : ubuntu
- What did you do? : (accidentally) called
lua.LTable.RawSetwith a nil key - What did you expect to see? : a panic
- What did you see instead? : a silently corrupted table
The C API doesn't work this way; try this:
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include <stdio.h>
int
main(void)
{
lua_State *L;
L = luaL_newstate();
luaL_openlibs(L);
lua_getglobal(L, "_G");
lua_pushnil(L);
lua_pushliteral(L, "whatever");
lua_rawset(L, -3);
lua_close(L);
return 0;
}
h/t to @hoelzro for helping me verify this