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
34398184
Kaydet (Commit)
34398184
authored
Ara 02, 2009
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #7406: Fix some occurrences of potential signed overflow in int
arithmetic.
üst
5a73ff81
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
intobject.c
Objects/intobject.c
+6
-3
ceval.c
Python/ceval.c
+6
-2
No files found.
Objects/intobject.c
Dosyayı görüntüle @
34398184
...
@@ -461,7 +461,8 @@ int_add(PyIntObject *v, PyIntObject *w)
...
@@ -461,7 +461,8 @@ int_add(PyIntObject *v, PyIntObject *w)
register
long
a
,
b
,
x
;
register
long
a
,
b
,
x
;
CONVERT_TO_LONG
(
v
,
a
);
CONVERT_TO_LONG
(
v
,
a
);
CONVERT_TO_LONG
(
w
,
b
);
CONVERT_TO_LONG
(
w
,
b
);
x
=
a
+
b
;
/* casts in the line below avoid undefined behaviour on overflow */
x
=
(
long
)((
unsigned
long
)
a
+
b
);
if
((
x
^
a
)
>=
0
||
(
x
^
b
)
>=
0
)
if
((
x
^
a
)
>=
0
||
(
x
^
b
)
>=
0
)
return
PyInt_FromLong
(
x
);
return
PyInt_FromLong
(
x
);
return
PyLong_Type
.
tp_as_number
->
nb_add
((
PyObject
*
)
v
,
(
PyObject
*
)
w
);
return
PyLong_Type
.
tp_as_number
->
nb_add
((
PyObject
*
)
v
,
(
PyObject
*
)
w
);
...
@@ -473,7 +474,8 @@ int_sub(PyIntObject *v, PyIntObject *w)
...
@@ -473,7 +474,8 @@ int_sub(PyIntObject *v, PyIntObject *w)
register
long
a
,
b
,
x
;
register
long
a
,
b
,
x
;
CONVERT_TO_LONG
(
v
,
a
);
CONVERT_TO_LONG
(
v
,
a
);
CONVERT_TO_LONG
(
w
,
b
);
CONVERT_TO_LONG
(
w
,
b
);
x
=
a
-
b
;
/* casts in the line below avoid undefined behaviour on overflow */
x
=
(
long
)((
unsigned
long
)
a
-
b
);
if
((
x
^
a
)
>=
0
||
(
x
^~
b
)
>=
0
)
if
((
x
^
a
)
>=
0
||
(
x
^~
b
)
>=
0
)
return
PyInt_FromLong
(
x
);
return
PyInt_FromLong
(
x
);
return
PyLong_Type
.
tp_as_number
->
nb_subtract
((
PyObject
*
)
v
,
return
PyLong_Type
.
tp_as_number
->
nb_subtract
((
PyObject
*
)
v
,
...
@@ -516,7 +518,8 @@ int_mul(PyObject *v, PyObject *w)
...
@@ -516,7 +518,8 @@ int_mul(PyObject *v, PyObject *w)
CONVERT_TO_LONG
(
v
,
a
);
CONVERT_TO_LONG
(
v
,
a
);
CONVERT_TO_LONG
(
w
,
b
);
CONVERT_TO_LONG
(
w
,
b
);
longprod
=
a
*
b
;
/* casts in the next line avoid undefined behaviour on overflow */
longprod
=
(
long
)((
unsigned
long
)
a
*
b
);
doubleprod
=
(
double
)
a
*
(
double
)
b
;
doubleprod
=
(
double
)
a
*
(
double
)
b
;
doubled_longprod
=
(
double
)
longprod
;
doubled_longprod
=
(
double
)
longprod
;
...
...
Python/ceval.c
Dosyayı görüntüle @
34398184
...
@@ -1321,7 +1321,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
...
@@ -1321,7 +1321,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
register
long
a
,
b
,
i
;
register
long
a
,
b
,
i
;
a
=
PyInt_AS_LONG
(
v
);
a
=
PyInt_AS_LONG
(
v
);
b
=
PyInt_AS_LONG
(
w
);
b
=
PyInt_AS_LONG
(
w
);
i
=
a
+
b
;
/* cast to avoid undefined behaviour
on overflow */
i
=
(
long
)((
unsigned
long
)
a
+
b
);
if
((
i
^
a
)
<
0
&&
(
i
^
b
)
<
0
)
if
((
i
^
a
)
<
0
&&
(
i
^
b
)
<
0
)
goto
slow_add
;
goto
slow_add
;
x
=
PyInt_FromLong
(
i
);
x
=
PyInt_FromLong
(
i
);
...
@@ -1351,7 +1353,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
...
@@ -1351,7 +1353,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
register
long
a
,
b
,
i
;
register
long
a
,
b
,
i
;
a
=
PyInt_AS_LONG
(
v
);
a
=
PyInt_AS_LONG
(
v
);
b
=
PyInt_AS_LONG
(
w
);
b
=
PyInt_AS_LONG
(
w
);
i
=
a
-
b
;
/* cast to avoid undefined behaviour
on overflow */
i
=
(
long
)((
unsigned
long
)
a
-
b
);
if
((
i
^
a
)
<
0
&&
(
i
^~
b
)
<
0
)
if
((
i
^
a
)
<
0
&&
(
i
^~
b
)
<
0
)
goto
slow_sub
;
goto
slow_sub
;
x
=
PyInt_FromLong
(
i
);
x
=
PyInt_FromLong
(
i
);
...
...
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