diff options
author | Armin Rigo <arigo@tunes.org> | 2006-07-06 07:58:18 (GMT) |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2006-07-06 07:58:18 (GMT) |
commit | 5953baca0a1f27b861f9db42a68f7777a62b4a3c (patch) | |
tree | 6bc06141b5dff4bcdf04c45067c89a901318d41c /Lib/test/crashers/borrowed_ref_1.py | |
parent | 43d9a58dfda44f453ef330fb9c05fbabb7b82591 (diff) | |
download | cpython-5953baca0a1f27b861f9db42a68f7777a62b4a3c.zip cpython-5953baca0a1f27b861f9db42a68f7777a62b4a3c.tar.gz cpython-5953baca0a1f27b861f9db42a68f7777a62b4a3c.tar.bz2 |
A couple of examples about how to attack the fact that _PyType_Lookup()
returns a borrowed ref. Many of the calls are open to attack.
Diffstat (limited to 'Lib/test/crashers/borrowed_ref_1.py')
-rw-r--r-- | Lib/test/crashers/borrowed_ref_1.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/crashers/borrowed_ref_1.py b/Lib/test/crashers/borrowed_ref_1.py new file mode 100644 index 0000000..d16ede2 --- /dev/null +++ b/Lib/test/crashers/borrowed_ref_1.py @@ -0,0 +1,29 @@ +""" +_PyType_Lookup() returns a borrowed reference. +This attacks the call in dictobject.c. +""" + +class A(object): + pass + +class B(object): + def __del__(self): + print 'hi' + del D.__missing__ + +class D(dict): + class __missing__: + def __init__(self, *args): + pass + + +d = D() +a = A() +a.cycle = a +a.other = B() +del a + +prev = None +while 1: + d[5] + prev = (prev,) |