[2716] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[PATCH] Don't leak editwins in the viewwin

daemon@ATHENA.MIT.EDU (David Benjamin)
Sat Oct 23 14:43:39 2010

From: David Benjamin <davidben@MIT.EDU>
To: barnowl-dev@mit.edu
Date: Sat, 23 Oct 2010 14:43:18 -0400

All the objects we pass the editwin to take a reference, but no one
ever claims the reference it was initially created with.
---
 viewwin.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/viewwin.c b/viewwin.c
index 32effdb..024dac8 100644
--- a/viewwin.c
+++ b/viewwin.c
@@ -216,6 +216,8 @@ char *owl_viewwin_command_start_search(owl_viewwin *v, int argc, const char *con
   owl_global_push_context_obj(&g, ctx);
   owl_editwin_set_callback(tw, owl_viewwin_callback_search);
   owl_editwin_set_cbdata(tw, data, owl_free);
+  /* We aren't saving tw, so release the reference we were given. */
+  owl_editwin_unref(tw);
   return NULL;
 }
 
@@ -235,6 +237,8 @@ char *owl_viewwin_start_command(owl_viewwin *v, int argc, const char *const *arg
                             owl_viewwin_deactivate_editcontext, v);
   owl_global_push_context_obj(&g, ctx);
   owl_editwin_set_callback(tw, owl_callback_command);
+  /* We aren't saving tw, so release the reference we were given. */
+  owl_editwin_unref(tw);
 
   return NULL;
 }
-- 
1.7.3.1.g716de


home help back first fref pref prev next nref lref last post