[pygi/null_out] Force out arguments to be initialized as NULL. Comes with a test.
- From: Zach Goldberg <zgoldberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygi/null_out] Force out arguments to be initialized as NULL. Comes with a test.
- Date: Mon, 26 Apr 2010 16:27:50 +0000 (UTC)
commit b0a650bc50b6573a7f1a068bd404c8db0daa5885
Author: Zach Goldberg <zach zachgoldberg com>
Date: Tue Apr 20 23:53:57 2010 -0400
Force out arguments to be initialized as NULL. Comes with a test.
This fix was motivated by a real world library which had a transfer full
utf8 out argument which sometimes was not set. We would leave the pointer
dangling and try and free it at the end of invoke() and crash. Library refused
to change their behavior so we're forced to take care of it on our end.
https://bugzilla.gnome.org/show_bug.cgi?id=616043
gi/pygi-info.c | 1 +
tests/test_gi.py | 3 +++
2 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 4f30fbf..3aa6dda 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -758,6 +758,7 @@ _wrap_g_function_info_invoke (PyGIBaseInfo *self,
case GI_DIRECTION_OUT:
g_assert(out_args_pos < n_out_args);
out_args[out_args_pos].v_pointer = &out_values[out_args_pos];
+ out_values[out_args_pos].v_pointer = NULL;
args[i] = &out_values[out_args_pos];
out_args_pos += 1;
}
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 7cab5db..d630398 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -646,6 +646,9 @@ class TestUtf8(unittest.TestCase):
def test_utf8_full_out(self):
self.assertEquals(CONSTANT_UTF8, GIMarshallingTests.utf8_full_out())
+ def test_utf8_dangling_out(self):
+ GIMarshallingTests.utf8_dangling_out()
+
def test_utf8_none_inout(self):
self.assertEquals("", GIMarshallingTests.utf8_none_inout(CONSTANT_UTF8))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]