diff options
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index f14e7daafe..9a9b98eb47 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -205,7 +205,7 @@ PyEval_GetCallStats(PyObject *self) #ifdef WITH_THREAD -#ifndef DONT_HAVE_ERRNO_H +#ifdef HAVE_ERRNO_H #include <errno.h> #endif #include "pythread.h" @@ -2740,7 +2740,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, /* Allocate and initialize storage for cell vars, and copy free vars into frame. This isn't too efficient right now. */ if (PyTuple_GET_SIZE(co->co_cellvars)) { - int i = 0, j = 0, nargs, found; + int i, j, nargs, found; char *cellname, *argname; PyObject *c; @@ -3318,7 +3318,7 @@ int PyEval_GetRestricted(void) { PyFrameObject *current_frame = PyEval_GetFrame(); - return current_frame == NULL ? 0 : current_frame->f_restricted; + return current_frame == NULL ? 0 : PyFrame_IsRestricted(current_frame); } int @@ -4187,6 +4187,14 @@ string_concatenate(PyObject *v, PyObject *w, { /* This function implements 'variable += expr' when both arguments are strings. */ + Py_ssize_t v_len = PyString_GET_SIZE(v); + Py_ssize_t w_len = PyString_GET_SIZE(w); + Py_ssize_t new_len = v_len + w_len; + if (new_len < 0) { + PyErr_SetString(PyExc_OverflowError, + "strings are too large to concat"); + return NULL; + } if (v->ob_refcnt == 2) { /* In the common case, there are 2 references to the value @@ -4231,9 +4239,7 @@ string_concatenate(PyObject *v, PyObject *w, /* Now we own the last reference to 'v', so we can resize it * in-place. */ - Py_ssize_t v_len = PyString_GET_SIZE(v); - Py_ssize_t w_len = PyString_GET_SIZE(w); - if (_PyString_Resize(&v, v_len + w_len) != 0) { + if (_PyString_Resize(&v, new_len) != 0) { /* XXX if _PyString_Resize() fails, 'v' has been * deallocated so it cannot be put back into 'variable'. * The MemoryError is raised when there is no value in |