Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
1cb2e042
Kaydet (Commit)
1cb2e042
authored
Mar 04, 2012
tarafından
Armin Rigo
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add a crasher for the documented issue of calling "Py_DECREF(self->xxx)";
üst
21ccb731
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
decref_before_assignment.py
Lib/test/crashers/decref_before_assignment.py
+44
-0
No files found.
Lib/test/crashers/decref_before_assignment.py
0 → 100644
Dosyayı görüntüle @
1cb2e042
"""
General example for an attack against code like this:
Py_DECREF(obj->attr); obj->attr = ...;
here in Module/_json.c:scanner_init().
Explanation: if the first Py_DECREF() calls either a __del__ or a
weakref callback, it will run while the 'obj' appears to have in
'obj->attr' still the old reference to the object, but not holding
the reference count any more.
Status: progress has been made replacing these cases, but there is an
infinite number of such cases.
"""
import
_json
,
weakref
class
Ctx1
(
object
):
encoding
=
"utf8"
strict
=
None
object_hook
=
None
object_pairs_hook
=
None
parse_float
=
None
parse_int
=
None
parse_constant
=
None
class
Foo
(
unicode
):
pass
def
delete_me
(
*
args
):
print
scanner
.
encoding
.
__dict__
class
Ctx2
(
Ctx1
):
@property
def
encoding
(
self
):
global
wref
f
=
Foo
(
"utf8"
)
f
.
abc
=
globals
()
wref
=
weakref
.
ref
(
f
,
delete_me
)
return
f
scanner
=
_json
.
make_scanner
(
Ctx1
())
scanner
.
__init__
(
Ctx2
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment