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
102764a1
Kaydet (Commit)
102764a1
authored
Eyl 12, 2015
tarafından
Kristján Valur Jónsson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #25021: Correctly make sure that product.__setstate__ does not access
invalid memory.
üst
a82f77fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
test_itertools.py
Lib/test/test_itertools.py
+10
-0
itertoolsmodule.c
Modules/itertoolsmodule.c
+10
-2
No files found.
Lib/test/test_itertools.py
Dosyayı görüntüle @
102764a1
...
...
@@ -959,6 +959,16 @@ class TestBasicOps(unittest.TestCase):
self
.
assertEqual
(
list
(
copy
.
deepcopy
(
product
(
*
args
))),
result
)
self
.
pickletest
(
product
(
*
args
))
def
test_product_issue_25021
(
self
):
# test that indices are properly clamped to the length of the tuples
p
=
product
((
1
,
2
),(
3
,))
p
.
__setstate__
((
0
,
0x1000
))
# will access tuple element 1 if not clamped
self
.
assertEqual
(
next
(
p
),
(
2
,
3
))
# test that empty tuple in the list will result in an immediate StopIteration
p
=
product
((
1
,
2
),
(),
(
3
,))
p
.
__setstate__
((
0
,
0
,
0x1000
))
# will access tuple element 1 if not clamped
self
.
assertRaises
(
StopIteration
,
next
,
p
)
def
test_repeat
(
self
):
self
.
assertEqual
(
list
(
repeat
(
object
=
'a'
,
times
=
3
)),
[
'a'
,
'a'
,
'a'
])
self
.
assertEqual
(
lzip
(
range
(
3
),
repeat
(
'a'
)),
...
...
Modules/itertoolsmodule.c
Dosyayı görüntüle @
102764a1
...
...
@@ -2205,13 +2205,21 @@ product_setstate(productobject *lz, PyObject *state)
{
PyObject
*
indexObject
=
PyTuple_GET_ITEM
(
state
,
i
);
Py_ssize_t
index
=
PyLong_AsSsize_t
(
indexObject
);
PyObject
*
pool
;
Py_ssize_t
poolsize
;
if
(
index
<
0
&&
PyErr_Occurred
())
return
NULL
;
/* not an integer */
pool
=
PyTuple_GET_ITEM
(
lz
->
pools
,
i
);
poolsize
=
PyTuple_GET_SIZE
(
pool
);
if
(
poolsize
==
0
)
{
lz
->
stopped
=
1
;
Py_RETURN_NONE
;
}
/* clamp the index */
if
(
index
<
0
)
index
=
0
;
else
if
(
index
>
n
-
1
)
index
=
n
-
1
;
else
if
(
index
>
poolsize
-
1
)
index
=
poolsize
-
1
;
lz
->
indices
[
i
]
=
index
;
}
...
...
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