diff options
author | Ken Bannister <kbee0916@earthlink.net> | 2012-09-11 06:06:06 -0400 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2012-09-11 16:07:29 +0200 |
commit | d3536c6c53f04aed73cbbd3144dd2ad2cad5fb62 (patch) | |
tree | e42da4447a6c5342adb184eea424f6d86de5d65d | |
parent | 59714054bfcbc01ee08f3bf49519de5f5668e4fb (diff) | |
download | lua-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.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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; } |