From 1cf5b9cd83d5adcca5e1352ab7c923968ec58f5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Sun, 9 Jan 2011 07:09:18 +0100 Subject: Make ld_lua_logdiag_register() a bit safer. --- src/ld-lua.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ld-lua.c b/src/ld-lua.c index 7976606..448e25c 100644 --- a/src/ld-lua.c +++ b/src/ld-lua.c @@ -406,12 +406,13 @@ ld_lua_logdiag_register (lua_State *L) lua_pop (L, 1); g_return_val_if_fail (ud != NULL, 0); - symbol = g_object_new (LD_TYPE_LUA_SYMBOL, NULL); - /* Use a protected environment, so script errors won't cause leaking - * of the symbol object. Only the failure of one of the following three - * function calls may cause the symbol to leak. + * of the symbol object. Only a failure of the last three function calls + * before lua_pcall() may cause the symbol to leak. */ + lua_checkstack (L, 3); + symbol = g_object_new (LD_TYPE_LUA_SYMBOL, NULL); + lua_pushlightuserdata (L, symbol); lua_pushcclosure (L, process_registration, 1); lua_insert (L, 1); -- cgit v1.2.3