[Python-checkins] cpython (merge 3.3 -> default): Issue #16971: Fix a refleak in the charmap decoder.
serhiy.storchaka
python-checkins at python.org
Tue Jan 29 11:17:57 CET 2013
http://hg.python.org/cpython/rev/02c4ecc87f74
changeset: 81826:02c4ecc87f74
parent: 81824:9b25df066f37
parent: 81825:625c397a7283
user: Serhiy Storchaka <storchaka at gmail.com>
date: Tue Jan 29 12:16:57 2013 +0200
summary:
Issue #16971: Fix a refleak in the charmap decoder.
files:
Objects/unicodeobject.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -7383,27 +7383,35 @@
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 {
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list