mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
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.
This commit is contained in:
parent
43d9a58dfd
commit
5953baca0a
2 changed files with 67 additions and 0 deletions
29
Lib/test/crashers/borrowed_ref_1.py
Normal file
29
Lib/test/crashers/borrowed_ref_1.py
Normal file
|
@ -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,)
|
Loading…
Add table
Add a link
Reference in a new issue