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
337c50b8
Kaydet (Commit)
337c50b8
authored
Ara 08, 2013
tarafından
Nadeem Vawda
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Closes #19878: Fix segfault in bz2 module.
Initial patch by Vajrasky Kok.
üst
7c573857
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
7 deletions
+25
-7
test_bz2.py
Lib/test/test_bz2.py
+12
-0
NEWS
Misc/NEWS
+3
-0
bz2module.c
Modules/bz2module.c
+10
-7
No files found.
Lib/test/test_bz2.py
Dosyayı görüntüle @
337c50b8
...
...
@@ -325,6 +325,18 @@ class BZ2FileTest(BaseTest):
self
.
assertRaises
(
ValueError
,
f
.
readline
)
self
.
assertRaises
(
ValueError
,
f
.
readlines
)
def
testInitNonExistentFile
(
self
):
# Issue #19878: Should not segfault when __init__ with non-existent
# file for the second time.
self
.
createTempFile
()
# Test close():
with
BZ2File
(
self
.
filename
,
"wb"
)
as
f
:
self
.
assertRaises
(
IOError
,
f
.
__init__
,
"non-existent-file"
)
# Test object deallocation without call to close():
f
=
bz2
.
BZ2File
(
self
.
filename
)
self
.
assertRaises
(
IOError
,
f
.
__init__
,
"non-existent-file"
)
del
f
class
BZ2CompressorTest
(
BaseTest
):
def
testCompress
(
self
):
# "Test BZ2Compressor.compress()/flush()"
...
...
Misc/NEWS
Dosyayı görüntüle @
337c50b8
...
...
@@ -15,6 +15,9 @@ Core and Builtins
Library
-------
- Issue #19878: Fix segfault in bz2 module after calling __init__ twice with
non-existent filename. Initial patch by Vajrasky Kok.
- Issue #16373: Prevent infinite recursion for ABC Set class comparisons.
- Issue #19138: doctest's IGNORE_EXCEPTION_DETAIL now allows a match when
...
...
Modules/bz2module.c
Dosyayı görüntüle @
337c50b8
...
...
@@ -1206,12 +1206,16 @@ BZ2File_close(BZ2FileObject *self)
0
,
NULL
,
NULL
);
break
;
}
if
(
self
->
fp
)
{
PyFile_DecUseCount
((
PyFileObject
*
)
self
->
file
);
self
->
fp
=
NULL
;
if
(
self
->
file
)
{
if
(
self
->
fp
)
PyFile_DecUseCount
((
PyFileObject
*
)
self
->
file
);
ret
=
PyObject_CallMethod
(
self
->
file
,
"close"
,
NULL
);
}
else
{
Py_INCREF
(
Py_None
);
ret
=
Py_None
;
}
self
->
fp
=
NULL
;
self
->
mode
=
MODE_CLOSED
;
ret
=
PyObject_CallMethod
(
self
->
file
,
"close"
,
NULL
);
if
(
bzerror
!=
BZ_OK
)
{
Util_CatchBZ2Error
(
bzerror
);
Py_XDECREF
(
ret
);
...
...
@@ -1479,10 +1483,9 @@ BZ2File_dealloc(BZ2FileObject *self)
0
,
NULL
,
NULL
);
break
;
}
if
(
self
->
fp
)
{
if
(
self
->
fp
!=
NULL
&&
self
->
file
!=
NULL
)
PyFile_DecUseCount
((
PyFileObject
*
)
self
->
file
);
self
->
fp
=
NULL
;
}
self
->
fp
=
NULL
;
Util_DropReadAhead
(
self
);
Py_XDECREF
(
self
->
file
);
Py_TYPE
(
self
)
->
tp_free
((
PyObject
*
)
self
);
...
...
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