commit d453538a9d8004061477707a8277a93235440b22
Author: SoaS user <olpc@localhost.localdomain>
Date:   Tue Sep 29 16:05:32 2009 +0200

    Fix memory leaks in python bindings (bug #596739).

diff --git a/python/vte.defs b/python/vte.defs
index 5fa028f..3e65395 100644
--- a/python/vte.defs
+++ b/python/vte.defs
@@ -551,6 +551,7 @@
   (parameters
     '("gboolean(*" "is_selected")
   )
+  (caller-owns-return #t)
 )
 
 (define-method get_text_include_trailing_spaces
@@ -560,6 +561,7 @@
   (parameters
     '("gboolean(*" "is_selected")
   )
+  (caller-owns-return #t)
 )
 
 (define-method get_text_range
@@ -573,6 +575,7 @@
     '("glong" "end_col")
     '("gboolean(*" "is_selected")
   )
+  (caller-owns-return #t)
 )
 
 (define-method get_cursor_position
@@ -658,6 +661,7 @@
     '("glong" "row")
     '("int*" "tag")
   )
+  (caller-owns-return #t)
 )
 
 (define-method set_emulation
diff --git a/python/vte.override b/python/vte.override
index 29c3316..d770e9e 100644
--- a/python/vte.override
+++ b/python/vte.override
@@ -340,6 +340,7 @@ _wrap_vte_terminal_get_text(PyGObject *self, PyObject *args, PyObject *kwargs)
     static char *kwlist[] = { "callback", "get_attributes", "data", NULL };
     PyObject *callback = NULL, *do_attr = NULL, *data = NULL;
     PyObject *callback_and_args = NULL;
+    PyObject *result = NULL;
     GArray *attrs = NULL;
     char *text;
     PyObject *py_attrs;
@@ -415,10 +416,13 @@ _wrap_vte_terminal_get_text(PyGObject *self, PyObject *args, PyObject *kwargs)
 	}
 	length = attrs->len;
 	g_array_free(attrs, TRUE);
-	return Py_BuildValue("(s#O)", text, length, py_attrs);
+	result = Py_BuildValue("(s#O)", text, length, py_attrs);
     } else {
-    	return Py_BuildValue("s", text);
+    	result = Py_BuildValue("s", text);
     }
+
+    g_free (text);
+    return result;
 }
 %%
 override vte_terminal_get_text_include_trailing_spaces kwargs
@@ -429,6 +433,7 @@ _wrap_vte_terminal_get_text_include_trailing_spaces(PyGObject *self, PyObject *a
     static char *kwlist[] = { "callback", "get_attributes", "data", NULL };
     PyObject *callback = NULL, *do_attr = NULL, *data = NULL;
     PyObject *callback_and_args = NULL;
+    PyObject *result = NULL;
     GArray *attrs = NULL;
     char *text;
     PyObject *py_attrs;
@@ -504,10 +509,12 @@ _wrap_vte_terminal_get_text_include_trailing_spaces(PyGObject *self, PyObject *a
 	}
 	length = attrs->len;
 	g_array_free(attrs, TRUE);
-	return Py_BuildValue("(s#O)", text, length, py_attrs);
+	result = Py_BuildValue("(s#O)", text, length, py_attrs);
     } else {
-    	return Py_BuildValue("s", text);
+    	result = Py_BuildValue("s", text);
     }
+    g_free (text);
+    return result;
 }
 %%
 override vte_terminal_get_text_range kwargs
@@ -519,6 +526,7 @@ _wrap_vte_terminal_get_text_range(PyGObject *self, PyObject *args, PyObject *kwa
     PyObject *callback = NULL, *do_attr = NULL, *data = NULL;
     glong start_row, start_col, end_row, end_col;
     PyObject *callback_and_args = NULL;
+    PyObject *result = NULL;
     GArray *attrs = NULL;
     char *text;
     PyObject *py_attrs;
@@ -601,10 +609,13 @@ _wrap_vte_terminal_get_text_range(PyGObject *self, PyObject *args, PyObject *kwa
 	}
 	length = attrs->len;
 	g_array_free(attrs, TRUE);
-	return Py_BuildValue("(s#O)", text, length, py_attrs);
+	result = Py_BuildValue("(s#O)", text, length, py_attrs);
     } else {
-    	return Py_BuildValue("s", text);
+    	result = Py_BuildValue("s", text);
     }
+
+    g_free (text);
+    return result;
 }
 %%
 override vte_terminal_set_colors kwargs
