From 56f6dc02be469043bc6004d4efc2bc1f3ff8914c Mon Sep 17 00:00:00 2001 From: "elias.bachaalany" Date: Thu, 24 Sep 2009 10:43:25 +0000 Subject: [PATCH] kernwin.i: fixed a reference leak --- swig/kernwin.i | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/swig/kernwin.i b/swig/kernwin.i index ce7cb35..ce97884 100644 --- a/swig/kernwin.i +++ b/swig/kernwin.i @@ -196,16 +196,17 @@ uint32 choose_choose(void *self, int width) { PyObject *pytitle; - - char deftitle[] = "Choose"; - char *title = NULL; - + const char *title; if ((pytitle = PyObject_GetAttrString((PyObject *)self, "title"))) { title = PyString_AsString(pytitle); } - - return choose( + else + { + title = "Choose"; + pytitle = NULL; + } + int r = choose( flags, x0, y0, x1, y1, @@ -213,7 +214,7 @@ uint32 choose_choose(void *self, width, &choose_sizer, &choose_getl, - title ? title : deftitle, + title, 1, 1, NULL, /* del */ @@ -224,7 +225,9 @@ uint32 choose_choose(void *self, NULL, /* destroy */ NULL, /* popup_names */ NULL /* get_icon */ - ); + ); + Py_XDECREF(pytitle); + return r; } %}