summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-09-06 21:25:30 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2015-09-06 21:25:30 +0300
commit51dfb6f71adbaf1e1d68ecacdfcf4a77be02e246 (patch)
tree269deaf808e88e1015408b3e11e920cd2900b890 /Python
parentabe3e1eb0d757e661158661bee7e1b678cb0380f (diff)
downloadcpython-51dfb6f71adbaf1e1d68ecacdfcf4a77be02e246.tar.gz
Issue #15989: Fixed some scarcely probable integer overflows.
It is very unlikely that they can occur in real code for now.
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-ast.c2
-rw-r--r--Python/pythonrun.c10
2 files changed, 6 insertions, 6 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 8a2dc7cc54..fd7f17e85b 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -769,7 +769,7 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
return 1;
}
- i = (int)PyLong_AsLong(obj);
+ i = _PyLong_AsInt(obj);
if (i == -1 && PyErr_Occurred())
return 1;
*out = i;
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index ebedd123f3..1a5dab5f3a 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -431,7 +431,7 @@ static int
parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,
int *lineno, int *offset, PyObject **text)
{
- long hold;
+ int hold;
PyObject *v;
_Py_IDENTIFIER(msg);
_Py_IDENTIFIER(filename);
@@ -464,11 +464,11 @@ parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,
v = _PyObject_GetAttrId(err, &PyId_lineno);
if (!v)
goto finally;
- hold = PyLong_AsLong(v);
+ hold = _PyLong_AsInt(v);
Py_DECREF(v);
if (hold < 0 && PyErr_Occurred())
goto finally;
- *lineno = (int)hold;
+ *lineno = hold;
v = _PyObject_GetAttrId(err, &PyId_offset);
if (!v)
@@ -477,11 +477,11 @@ parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,
*offset = -1;
Py_DECREF(v);
} else {
- hold = PyLong_AsLong(v);
+ hold = _PyLong_AsInt(v);
Py_DECREF(v);
if (hold < 0 && PyErr_Occurred())
goto finally;
- *offset = (int)hold;
+ *offset = hold;
}
v = _PyObject_GetAttrId(err, &PyId_text);