-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lua_pushstring failures result in leaked memory #5
Comments
Possible solution via static int pointer_to_string (lua_State *L) {
lua_pushstring(L, lua_topointer(L, 1))
return 1;
}
static void pushstring_and_free (lua_State *L, char* str) {
int err;
lua_pushcfunction(L, pointer_to_string);
lua_pushlightuserdata(L, str);
err = lua_pcall(L, 1, 1, 0);
free(str);
if (LUA_OK != err) lua_error(L);
}
.....
pushstring_and_free(L, str); Uses |
Alternative solution is via allocating a copy (via e.g. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If
lua_pushstring
longjmp
s out then the string is never freed.e.g.
lua-systemd/src/login.c
Line 129 in f905300
The text was updated successfully, but these errors were encountered: