diff options
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 2977bcd..f03e488 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -2923,20 +2923,20 @@ filterstring(PyObject *func, PyObject *strobj) if (need<2*outlen) { need = 2*outlen; - } - if (_PyString_Resize(&result, need)) { - Py_DECREF(item); - return NULL; - } - outlen = need; - } - memcpy( - PyString_AS_STRING(result) + j, - PyString_AS_STRING(item), - reslen - ); - j += reslen; } + if (_PyString_Resize(&result, need)) { + Py_DECREF(item); + return NULL; + } + outlen = need; + } + memcpy( + PyString_AS_STRING(result) + j, + PyString_AS_STRING(item), + reslen + ); + j += reslen; + } } Py_DECREF(item); if (ok < 0) @@ -3031,29 +3031,27 @@ filterunicode(PyObject *func, PyObject *strobj) assert(outlen >= 0); if (need > outlen) { - /* overallocate, - to avoid reallocations */ + /* overallocate, to avoid reallocations */ if (need < 2 * outlen) { - if (outlen > PY_SSIZE_T_MAX / 2) { - Py_DECREF(item); - return NULL; - } else { - need = 2 * outlen; - } - } - - if (PyUnicode_Resize( - &result, need) < 0) { - Py_DECREF(item); - goto Fail_1; - } - outlen = need; - } - memcpy(PyUnicode_AS_UNICODE(result) + j, - PyUnicode_AS_UNICODE(item), - reslen*sizeof(Py_UNICODE)); - j += reslen; + if (outlen > PY_SSIZE_T_MAX / 2) { + Py_DECREF(item); + return NULL; + } else { + need = 2 * outlen; + } } + + if (PyUnicode_Resize(&result, need) < 0) { + Py_DECREF(item); + goto Fail_1; + } + outlen = need; + } + memcpy(PyUnicode_AS_UNICODE(result) + j, + PyUnicode_AS_UNICODE(item), + reslen*sizeof(Py_UNICODE)); + j += reslen; + } } Py_DECREF(item); if (ok < 0) |