From d3536c6c53f04aed73cbbd3144dd2ad2cad5fb62 Mon Sep 17 00:00:00 2001 From: Ken Bannister Date: Tue, 11 Sep 2012 06:06:06 -0400 Subject: Rework Paug_close() to work with raw augeas** rather than augeas*. Was attempting to null the augeas*, but this was ineffective. Caused a segfault if manually closed the library because aug_close() would be called twice -- once for manual close, and once for __gc based close. --- laugeas.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/laugeas.c b/laugeas.c index 8e0a593..68606b2 100644 --- a/laugeas.c +++ b/laugeas.c @@ -128,10 +128,14 @@ static int Paug_defnode(lua_State *L) static int Paug_close(lua_State *L) { - augeas *a = Paug_checkarg(L, 1); - if (a) - aug_close(a); - a = NULL; + augeas **a; + luaL_checktype(L, 1, LUA_TUSERDATA); + a = (augeas **) luaL_checkudata(L, 1, PAUG_META); + + if (a && *a) { + aug_close(*a); + *a = NULL; + } return 0; } -- cgit v1.2.3