aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2011-01-09 07:09:18 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2011-01-09 07:09:18 +0100
commit1cf5b9cd83d5adcca5e1352ab7c923968ec58f5e (patch)
tree10637f587108da110db88d62051cc63dfa8a08b0 /src
parent54ef5ce450725e0594a93543d4de5914e2b5e102 (diff)
downloadlogdiag-1cf5b9cd83d5adcca5e1352ab7c923968ec58f5e.tar.gz
logdiag-1cf5b9cd83d5adcca5e1352ab7c923968ec58f5e.tar.xz
logdiag-1cf5b9cd83d5adcca5e1352ab7c923968ec58f5e.zip
Make ld_lua_logdiag_register() a bit safer.
Diffstat (limited to 'src')
-rw-r--r--src/ld-lua.c9
1 files changed, 5 insertions, 4 deletions
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);