summaryrefslogtreecommitdiffstats
path: root/Objects/frameobject.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2007-12-04 22:10:37 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2007-12-04 22:10:37 (GMT)
commitd1a1d1ed802187cd1a9a8a95ac5d758c7acffee6 (patch)
tree17489e6ea4df32ba3b3bbda6e4b31155a460f265 /Objects/frameobject.c
parent0fbab7ff8d2efd92e222fcc13c0aff0998c3c158 (diff)
downloadcpython-d1a1d1ed802187cd1a9a8a95ac5d758c7acffee6.zip
cpython-d1a1d1ed802187cd1a9a8a95ac5d758c7acffee6.tar.gz
cpython-d1a1d1ed802187cd1a9a8a95ac5d758c7acffee6.tar.bz2
Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Diffstat (limited to 'Objects/frameobject.c')
-rw-r--r--Objects/frameobject.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 0e6d9f8..266cbd2 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -66,6 +66,8 @@ static int
frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
{
int new_lineno = 0; /* The new value of f_lineno */
+ long l_new_lineno;
+ int overflow;
int new_lasti = 0; /* The new value of f_lasti */
int new_iblock = 0; /* The new value of f_iblock */
unsigned char *code = NULL; /* The bytecode for the frame... */
@@ -88,7 +90,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
unsigned char setup_op = 0; /* (ditto) */
/* f_lineno must be an integer. */
- if (!PyInt_CheckExact(p_new_lineno)) {
+ if (!PyLong_CheckExact(p_new_lineno)) {
PyErr_SetString(PyExc_ValueError,
"lineno must be an integer");
return -1;
@@ -104,7 +106,19 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
}
/* Fail if the line comes before the start of the code block. */
- new_lineno = (int) PyLong_AsLong(p_new_lineno);
+ l_new_lineno = PyLong_AsLongAndOverflow(p_new_lineno, &overflow);
+ if (overflow
+#if SIZEOF_LONG > SIZEOF_INT
+ || l_new_lineno > INT_MAX
+ || l_new_lineno < INT_MIN
+#endif
+ ) {
+ PyErr_SetString(PyExc_ValueError,
+ "lineno out of range");
+ return -1;
+ }
+ new_lineno = (int)l_new_lineno;
+
if (new_lineno < f->f_code->co_firstlineno) {
PyErr_Format(PyExc_ValueError,
"line %d comes before the current code block",