[pygobject] Fix crash in GList/GSList marshaling error handling path.
- From: Simon Feltman <sfeltman src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Fix crash in GList/GSList marshaling error handling path.
- Date: Fri, 22 Aug 2014 00:15:05 +0000 (UTC)
commit b7a4e68a224ab66f67e45667023f74dd743e6177
Author: Christoph Reiter <reiter christoph gmail com>
Date: Fri Aug 22 01:04:40 2014 +0200
Fix crash in GList/GSList marshaling error handling path.
In case PySequence_GetItem() failed, the retured NULL was passed to PyDECREF.
https://bugzilla.gnome.org/show_bug.cgi?id=735201
gi/pygi-list.c | 4 ++--
tests/test_gi.py | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/gi/pygi-list.c b/gi/pygi-list.c
index f6589c1..e3f3c67 100644
--- a/gi/pygi-list.c
+++ b/gi/pygi-list.c
@@ -82,7 +82,7 @@ err:
PyGIMarshalCleanupFunc cleanup = sequence_cache->item_cache->from_py_cleanup;
}
*/
- Py_DECREF (py_item);
+ Py_XDECREF (py_item);
g_list_free (list_);
_PyGI_ERROR_PREFIX ("Item %i: ", i);
return FALSE;
@@ -160,7 +160,7 @@ err:
}
*/
- Py_DECREF (py_item);
+ Py_XDECREF (py_item);
g_slist_free (list_);
_PyGI_ERROR_PREFIX ("Item %i: ", i);
return FALSE;
diff --git a/tests/test_gi.py b/tests/test_gi.py
index d4ce662..e8c3aad 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -1117,6 +1117,14 @@ class TestGList(unittest.TestCase):
self.assertRaises(TypeError, GIMarshallingTests.glist_int_none_in, 42)
self.assertRaises(TypeError, GIMarshallingTests.glist_int_none_in, None)
+ def test_glist_int_none_in_error_getitem(self):
+
+ class FailingSequence(Sequence):
+ def __getitem__(self, key):
+ raise Exception
+
+ self.assertRaises(Exception, GIMarshallingTests.glist_int_none_in, FailingSequence((-1, 0, 1, 2)))
+
def test_glist_uint32_none_in(self):
GIMarshallingTests.glist_uint32_none_in(Sequence((0, GObject.G_MAXUINT32)))
@@ -1164,6 +1172,14 @@ class TestGSList(unittest.TestCase):
self.assertRaises(TypeError, GIMarshallingTests.gslist_int_none_in, 42)
self.assertRaises(TypeError, GIMarshallingTests.gslist_int_none_in, None)
+ def test_gslist_int_none_in_error_getitem(self):
+
+ class FailingSequence(Sequence):
+ def __getitem__(self, key):
+ raise Exception
+
+ self.assertRaises(Exception, GIMarshallingTests.gslist_int_none_in, FailingSequence((-1, 0, 1, 2)))
+
def test_gslist_utf8_none_in(self):
GIMarshallingTests.gslist_utf8_none_in(Sequence(('0', '1', '2')))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]