summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Pogonyshev <pogonyshev@gmx.net>2008-06-24 18:42:25 +0000
committerPaul Pogonyshev <paulp@src.gnome.org>2008-06-24 18:42:25 +0000
commita35a35b10fa2badeece2ccb857f64bac1f69f5af (patch)
treeb9cfd3f013d8ca9f82bd9a8861e6fee2b4638104 /tests
parent858b5fa7d569ebef07c76f6bef963de63ca7d530 (diff)
downloadpygtk-a35a35b10fa2badeece2ccb857f64bac1f69f5af.tar.gz
Fix logic in negative index branch to avoid refcount corruption.
2008-06-24 Paul Pogonyshev <pogonyshev@gmx.net> * gtk/gtktreeview.override (_wrap_gtk_tree_model_tp_getitem): Fix logic in negative index branch to avoid refcount corruption. (_wrap_gtk_tree_model_tp_setitem): Likewise (bug #537459). * tests/test_liststore.py (ListStoreTest.testNegativeIndexGet) (ListStoreTest.testNegativeIndexSet): Two new tests for the bug. svn path=/trunk/; revision=2999
Diffstat (limited to 'tests')
-rw-r--r--tests/test_liststore.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_liststore.py b/tests/test_liststore.py
index da53a07e..87dd5945 100644
--- a/tests/test_liststore.py
+++ b/tests/test_liststore.py
@@ -32,5 +32,23 @@ class ListStoreTest(unittest.TestCase):
store.set_default_sort_func(None)
self.failIf(store.has_default_sort_func())
+ # Two tests for bug 537459. Since it is a memory corruption, we
+ # use a large loop count hoping to trigger a segfault.
+
+ def testNegativeIndexGet(self):
+ store = gtk.ListStore(int)
+ for i in range(200):
+ store.append((i,))
+ self.assertEqual(store[-1][0], i)
+
+ def testNegativeIndexSet(self):
+ store = gtk.ListStore(int)
+ for i in range(200):
+ store.append((i,))
+ del store[-1]
+ self.assert_(len(store) == 0)
+
+
+
if __name__ == '__main__':
unittest.main()