[Python-checkins] cpython (3.3): Issue #16971: Fix a refleak in the charmap decoder.

serhiy.storchaka python-checkins at python.org
Tue Jan 29 11:17:55 CET 2013


http://hg.python.org/cpython/rev/625c397a7283
changeset: 81825:625c397a7283
branch: 3.3
parent: 81823:cbada2ea6dd3
user: Serhiy Storchaka <storchaka at gmail.com>
date: Tue Jan 29 12:13:22 2013 +0200
summary:
 Issue #16971: Fix a refleak in the charmap decoder.
files:
 Objects/unicodeobject.c | 17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -7510,14 +7510,18 @@
 Py_DECREF(x);
 goto onError;
 }
- if (unicode_putchar(&v, &outpos, value) < 0)
+ if (unicode_putchar(&v, &outpos, value) < 0) {
+ Py_DECREF(x);
 goto onError;
+ }
 }
 else if (PyUnicode_Check(x)) {
 Py_ssize_t targetsize;
 
- if (PyUnicode_READY(x) == -1)
+ if (PyUnicode_READY(x) == -1) {
+ Py_DECREF(x);
 goto onError;
+ }
 targetsize = PyUnicode_GET_LENGTH(x);
 
 if (targetsize == 1) {
@@ -7525,8 +7529,10 @@
 Py_UCS4 value = PyUnicode_READ_CHAR(x, 0);
 if (value == 0xFFFE)
 goto Undefined;
- if (unicode_putchar(&v, &outpos, value) < 0)
+ if (unicode_putchar(&v, &outpos, value) < 0) {
+ Py_DECREF(x);
 goto onError;
+ }
 }
 else if (targetsize > 1) {
 /* 1-n mapping */
@@ -7543,8 +7549,11 @@
 goto onError;
 }
 }
- if (unicode_widen(&v, outpos, PyUnicode_MAX_CHAR_VALUE(x)) < 0)
+ if (unicode_widen(&v, outpos,
+ PyUnicode_MAX_CHAR_VALUE(x)) < 0) {
+ Py_DECREF(x);
 goto onError;
+ }
 PyUnicode_CopyCharacters(v, outpos, x, 0, targetsize);
 outpos += targetsize;
 extrachars -= targetsize;
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /