From 0a7bec1dbb5717debcced2ed6e9fef301071afaa Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 17 Sep 2010 15:45:24 +0200 Subject: [PATCH] Correctly unref widget_nodes While drawing the wibox, the C core builds up a list of widgets and their associated geometry. This list consists of widget_node_t objects and is constructed like this (This is from luaA_table2widgets()): widget_node_t w; p_clear(&w, 1); w.widget = luaA_object_ref_item(L, idx, -1); widget_node_array_append(widgets, w); After we are done with this list of widget nodes, it is freed via wibox_widget_node_array_wipe(). However, wibox_widget_node_array_wipe() passed "&w" to luaA_object_unref_item() while it should have used "w.widget" (which is what was returned from luaA_object_ref_item()). This made the unref fail and the wibox was carrying around a reference to this widget forever. This was effectively a memory leak. Signed-off-by: Uli Schlachter --- objects/wibox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objects/wibox.c b/objects/wibox.c index fb5ef960..066dbbff 100644 --- a/objects/wibox.c +++ b/objects/wibox.c @@ -94,7 +94,7 @@ wibox_widget_node_array_wipe(lua_State *L, int idx) { wibox_t *wibox = luaA_checkudata(L, idx, &wibox_class); foreach(widget_node, wibox->widgets) - luaA_object_unref_item(globalconf.L, idx, widget_node); + luaA_object_unref_item(globalconf.L, idx, widget_node->widget); widget_node_array_wipe(&wibox->widgets); }