diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-29 10:16:57 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-29 10:16:57 (GMT) |
commit | 2aee6a6460d8e748ce5d44b15c8219a57c2be0b9 (patch) | |
tree | a1bdcedda6d4272a879567768db52f03a68f5e9f /Objects/unicodeobject.c | |
parent | 6de7099165691a7c5f64f052fe8c096471096b17 (diff) | |
parent | afb1cb55793669b70f355540389409cedc731d93 (diff) | |
download | cpython-2aee6a6460d8e748ce5d44b15c8219a57c2be0b9.zip cpython-2aee6a6460d8e748ce5d44b15c8219a57c2be0b9.tar.gz cpython-2aee6a6460d8e748ce5d44b15c8219a57c2be0b9.tar.bz2 |
Issue #16971: Fix a refleak in the charmap decoder.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 6eaccbe..cbd2870 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -7383,27 +7383,35 @@ Error: goto onError; } - if (_PyUnicodeWriter_Prepare(&writer, 1, value) == -1) + if (_PyUnicodeWriter_Prepare(&writer, 1, value) == -1) { + Py_DECREF(x); goto onError; + } PyUnicode_WRITE(writer.kind, writer.data, writer.pos, value); writer.pos++; } else if (PyUnicode_Check(x)) { - if (PyUnicode_READY(x) == -1) + if (PyUnicode_READY(x) == -1) { + Py_DECREF(x); goto onError; + } if (PyUnicode_GET_LENGTH(x) == 1) { Py_UCS4 value = PyUnicode_READ_CHAR(x, 0); if (value == 0xFFFE) goto Undefined; - if (_PyUnicodeWriter_Prepare(&writer, 1, value) == -1) + if (_PyUnicodeWriter_Prepare(&writer, 1, value) == -1) { + Py_DECREF(x); goto onError; + } PyUnicode_WRITE(writer.kind, writer.data, writer.pos, value); writer.pos++; } else { writer.overallocate = 1; - if (_PyUnicodeWriter_WriteStr(&writer, x) == -1) + if (_PyUnicodeWriter_WriteStr(&writer, x) == -1) { + Py_DECREF(x); goto onError; + } } } else { |