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
4cee049f
Kaydet (Commit)
4cee049f
authored
Şub 22, 2017
tarafından
Xiang Zhang
Kaydeden (comit)
GitHub
Şub 22, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-27660: remove unnecessary overflow checks in list_resize (GH-189)
üst
3e8d6cb1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
12 deletions
+7
-12
listobject.c
Objects/listobject.c
+7
-12
No files found.
Objects/listobject.c
Dosyayı görüntüle @
4cee049f
...
...
@@ -26,7 +26,7 @@ static int
list_resize
(
PyListObject
*
self
,
Py_ssize_t
newsize
)
{
PyObject
**
items
;
size_t
new_allocated
;
size_t
new_allocated
,
num_allocated_bytes
;
Py_ssize_t
allocated
=
self
->
allocated
;
/* Bypass realloc() when a previous overallocation is large enough
...
...
@@ -45,24 +45,19 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
* sequence of appends() in the presence of a poorly-performing
* system realloc().
* The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ...
* Note: new_allocated won't overflow because the largest possible value
* is PY_SSIZE_T_MAX * (9 / 8) + 6 which always fits in a size_t.
*/
new_allocated
=
(
newsize
>>
3
)
+
(
newsize
<
9
?
3
:
6
);
/* check for integer overflow */
if
(
new_allocated
>
SIZE_MAX
-
newsize
)
{
new_allocated
=
(
size_t
)
newsize
+
(
newsize
>>
3
)
+
(
newsize
<
9
?
3
:
6
);
if
(
new_allocated
>
(
size_t
)
PY_SSIZE_T_MAX
/
sizeof
(
PyObject
*
))
{
PyErr_NoMemory
();
return
-
1
;
}
else
{
new_allocated
+=
newsize
;
}
if
(
newsize
==
0
)
new_allocated
=
0
;
items
=
self
->
ob_item
;
if
(
new_allocated
<=
(
SIZE_MAX
/
sizeof
(
PyObject
*
)))
PyMem_RESIZE
(
items
,
PyObject
*
,
new_allocated
);
else
items
=
NULL
;
num_allocated_bytes
=
new_allocated
*
sizeof
(
PyObject
*
);
items
=
(
PyObject
**
)
PyMem_Realloc
(
self
->
ob_item
,
num_allocated_bytes
);
if
(
items
==
NULL
)
{
PyErr_NoMemory
();
return
-
1
;
...
...
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