Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 39469:71baa06767dd legacy-trunk
Fix segfault when doing string formatting on subclasses of long if
__oct__, __hex__ don't return a string.
Klocwork 308
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Sun, 13 Aug 2006 18:11:08 +0000 |
| parents | 6cafdc81cfde |
| children | a95090281032 |
line wrap: on
line diff
--- a/Objects/stringobject.c Sun Aug 13 18:10:47 2006 +0000 +++ b/Objects/stringobject.c Sun Aug 13 18:11:08 2006 +0000 @@ -4225,12 +4225,15 @@ if (!result) return NULL; + buf = PyString_AsString(result); + if (!buf) + return NULL; + /* To modify the string in-place, there can only be one reference. */ if (result->ob_refcnt != 1) { PyErr_BadInternalCall(); return NULL; } - buf = PyString_AsString(result); llen = PyString_Size(result); if (llen > PY_SSIZE_T_MAX) { PyErr_SetString(PyExc_ValueError, "string too large in _PyString_FormatLong");
