summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Bannister <kbee0916@earthlink.net>2012-09-11 06:06:06 -0400
committerNatanael Copa <ncopa@alpinelinux.org>2012-09-11 16:07:29 +0200
commitd3536c6c53f04aed73cbbd3144dd2ad2cad5fb62 (patch)
treee42da4447a6c5342adb184eea424f6d86de5d65d
parent59714054bfcbc01ee08f3bf49519de5f5668e4fb (diff)
downloadlua-augeas-d3536c6c53f04aed73cbbd3144dd2ad2cad5fb62.tar.bz2
lua-augeas-d3536c6c53f04aed73cbbd3144dd2ad2cad5fb62.tar.xz
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.
-rw-r--r--laugeas.c12
1 files 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;
}