diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-10-26 22:05:06 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-10-26 22:05:06 (GMT) |
commit | 1daebdf82ce6b50a105ff37b6e279ce1390732f7 (patch) | |
tree | d00720b47d5adb0fdcd48579b9e3816d2ee545b7 /Objects | |
parent | f972488213c359e251d6a0b06759ce19ef33e48d (diff) | |
download | cpython-1daebdf82ce6b50a105ff37b6e279ce1390732f7.zip cpython-1daebdf82ce6b50a105ff37b6e279ce1390732f7.tar.gz cpython-1daebdf82ce6b50a105ff37b6e279ce1390732f7.tar.bz2 |
Make sure memory is freed on error in complex_subtype_from_string.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/complexobject.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c index b541308..e5e07c1 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -750,10 +750,8 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v) if (PyUnicode_EncodeDecimal(PyUnicode_AS_UNICODE(v), PyUnicode_GET_SIZE(v), s_buffer, - NULL)) { - PyMem_FREE(s_buffer); - return NULL; - } + NULL)) + goto error; s = s_buffer; len = strlen(s); } @@ -802,7 +800,7 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v) if (PyErr_ExceptionMatches(PyExc_ValueError)) PyErr_Clear(); else - return NULL; + goto error; } if (end != s) { /* all 4 forms starting with <float> land here */ @@ -815,7 +813,7 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v) if (PyErr_ExceptionMatches(PyExc_ValueError)) PyErr_Clear(); else - return NULL; + goto error; } if (end != s) /* <float><signed-float>j */ @@ -875,10 +873,11 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v) return complex_subtype_from_doubles(type, x, y); parse_error: - if (s_buffer) - PyMem_FREE(s_buffer); PyErr_SetString(PyExc_ValueError, "complex() arg is a malformed string"); + error: + if (s_buffer) + PyMem_FREE(s_buffer); return NULL; } |