From 43902aed69224f08174ca6066b76190c2b9b6fad Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 8 May 2009 09:53:20 +0200 Subject: [PATCH] luaa: fix memory leak in __gc We need to wipe the ref_array. Signed-off-by: Julien Danjou --- button.c | 1 + client.c | 1 + image.c | 1 + key.c | 1 + tag.c | 1 + wibox.c | 1 + widget.c | 1 + 7 files changed, 7 insertions(+) diff --git a/button.c b/button.c index ab3186434..0efc28241 100644 --- a/button.c +++ b/button.c @@ -40,6 +40,7 @@ static int luaA_button_gc(lua_State *L) { button_t *button = luaL_checkudata(L, 1, "button"); + luaA_ref_array_wipe(&button->refs); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, button->press); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, button->release); return 0; diff --git a/client.c b/client.c index ec1d5651c..111d4562e 100644 --- a/client.c +++ b/client.c @@ -51,6 +51,7 @@ static int luaA_client_gc(lua_State *L) { client_t *c = luaL_checkudata(L, 1, "client"); + luaA_ref_array_wipe(&c->refs); button_array_wipe(&c->buttons); image_unref(L, c->icon); p_delete(&c->class); diff --git a/image.c b/image.c index 1454f275d..d36a74a23 100644 --- a/image.c +++ b/image.c @@ -28,6 +28,7 @@ static int luaA_image_gc(lua_State *L) { image_t *p = luaL_checkudata(L, 1, "image"); + luaA_ref_array_wipe(&p->refs); imlib_context_set_image(p->image); imlib_free_image(); p_delete(&p->data); diff --git a/key.c b/key.c index 6b4267510..6460e38f3 100644 --- a/key.c +++ b/key.c @@ -50,6 +50,7 @@ static int luaA_key_gc(lua_State *L) { keyb_t *kbp = luaL_checkudata(L, 1, "key"); + luaA_ref_array_wipe(&kbp->refs); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, kbp->press); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, kbp->release); return 0; diff --git a/tag.c b/tag.c index 1fb1cfe5a..96589d5e7 100644 --- a/tag.c +++ b/tag.c @@ -41,6 +41,7 @@ static int luaA_tag_gc(lua_State *L) { tag_t *tag = luaL_checkudata(L, 1, "tag"); + luaA_ref_array_wipe(&tag->refs); client_array_wipe(&tag->clients); p_delete(&tag->name); return 0; diff --git a/wibox.c b/wibox.c index 0b1e31645..48cf3dc93 100644 --- a/wibox.c +++ b/wibox.c @@ -39,6 +39,7 @@ static int luaA_wibox_gc(lua_State *L) { wibox_t *wibox = luaL_checkudata(L, 1, "wibox"); + luaA_ref_array_wipe(&wibox->refs); p_delete(&wibox->cursor); simplewindow_wipe(&wibox->sw); button_array_wipe(&wibox->buttons); diff --git a/widget.c b/widget.c index f8c00e3db..e48bfe28c 100644 --- a/widget.c +++ b/widget.c @@ -44,6 +44,7 @@ static int luaA_widget_gc(lua_State *L) { widget_t *widget = luaL_checkudata(L, 1, "widget"); + luaA_ref_array_wipe(&widget->refs); if(widget->destructor) widget->destructor(widget); button_array_wipe(&widget->buttons);