Mercurial > cpython-lru_cache-weakref
comparison Objects/stringobject.c @ 40006:f6bbe8d6fa33 2.4
[Backport r51248 | neal.norwitz]
Fix segfault when doing string formatting on subclasses of long if
__oct__, __hex__ don't return a string.
Klocwork 308
| author | Andrew M. Kuchling <amk@amk.ca> |
|---|---|
| date | Thu, 05 Oct 2006 17:18:13 +0000 |
| parents | a9b1f404e88b |
| children | 2a05ee4a23e0 |
comparison
equal
deleted
inserted
replaced
| 40005:a4bbfca40c7c | 40006:f6bbe8d6fa33 |
|---|---|
| 3663 assert(!"'type' not in [duoxX]"); | 3663 assert(!"'type' not in [duoxX]"); |
| 3664 } | 3664 } |
| 3665 if (!result) | 3665 if (!result) |
| 3666 return NULL; | 3666 return NULL; |
| 3667 | 3667 |
| 3668 buf = PyString_AsString(result); | |
| 3669 if (!buf) | |
| 3670 return NULL; | |
| 3671 | |
| 3668 /* To modify the string in-place, there can only be one reference. */ | 3672 /* To modify the string in-place, there can only be one reference. */ |
| 3669 if (result->ob_refcnt != 1) { | 3673 if (result->ob_refcnt != 1) { |
| 3670 PyErr_BadInternalCall(); | 3674 PyErr_BadInternalCall(); |
| 3671 return NULL; | 3675 return NULL; |
| 3672 } | 3676 } |
| 3673 buf = PyString_AsString(result); | |
| 3674 len = PyString_Size(result); | 3677 len = PyString_Size(result); |
| 3675 if (buf[len-1] == 'L') { | 3678 if (buf[len-1] == 'L') { |
| 3676 --len; | 3679 --len; |
| 3677 buf[len] = '\0'; | 3680 buf[len] = '\0'; |
| 3678 } | 3681 } |
