[Python-Dev] cpython: fix some possible refleaks from PyUnicode_READY error conditions
Benjamin Peterson
benjamin at python.org
Mon Jan 2 16:07:54 CET 2012
2012/1/2 Antoine Pitrou <solipsis at pitrou.net>:
> On Mon, 02 Jan 2012 16:00:50 +0100
> benjamin.peterson <python-checkins at python.org> wrote:
>> http://hg.python.org/cpython/rev/d5cda62d0f8c
>> changeset: 74236:d5cda62d0f8c
>> user: Benjamin Peterson <benjamin at python.org>
>> date: Mon Jan 02 09:00:30 2012 -0600
>> summary:
>> fix some possible refleaks from PyUnicode_READY error conditions
>>
>> files:
>> Objects/unicodeobject.c | 80 ++++++++++++++++++++--------
>> 1 files changed, 56 insertions(+), 24 deletions(-)
>>
>>
>> diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
>> --- a/Objects/unicodeobject.c
>> +++ b/Objects/unicodeobject.c
>> @@ -9132,10 +9132,15 @@
>> Py_ssize_t len1, len2;
>>
>> str_obj = PyUnicode_FromObject(str);
>> - if (!str_obj || PyUnicode_READY(str_obj) == -1)
>> + if (!str_obj)
>> return -1;
>> sub_obj = PyUnicode_FromObject(substr);
>> - if (!sub_obj || PyUnicode_READY(sub_obj) == -1) {
>> + if (!sub_obj) {
>> + Py_DECREF(str_obj);
>> + return -1;
>> + }
>> + if (PyUnicode_READY(substr) == -1 || PyUnicode_READY(str_obj) == -1) {
>
> Shouldn't the first one be PyUnicode_READY(sub_obj) ?
Yes.
--
Regards,
Benjamin
More information about the Python-Dev
mailing list