summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2003-08-14 20:25:29 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2003-08-14 20:25:29 (GMT)
commite5402fb340c5eea54858def3c5c294552a5f9faa (patch)
tree9e1c7405ecf74436e4442e39d08d9d5160b47174 /Objects
parentfb857893a2a9885bb872f8729d1a4dfc00762134 (diff)
downloadcpython-e5402fb340c5eea54858def3c5c294552a5f9faa.zip
cpython-e5402fb340c5eea54858def3c5c294552a5f9faa.tar.gz
cpython-e5402fb340c5eea54858def3c5c294552a5f9faa.tar.bz2
Fix refcount leak in PyUnicode_EncodeCharmap(). The bug surfaces
when an encoding error occurs and the callback name is unknown, i.e. when the callback has to be called. The problem was that the fact that the callback has already been looked up was only recorded in a local variable in charmap_encoding_error(), because charmap_encoding_error() got it's own copy of the errorHandler pointer instead of a pointer to the pointer in PyUnicode_EncodeCharmap().
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index b165597..6044a56 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -2876,7 +2876,7 @@ static
int charmap_encoding_error(
const Py_UNICODE *p, int size, int *inpos, PyObject *mapping,
PyObject **exceptionObject,
- int *known_errorHandler, PyObject *errorHandler, const char *errors,
+ int *known_errorHandler, PyObject **errorHandler, const char *errors,
PyObject **res, int *respos)
{
PyObject *repunicode = NULL; /* initialize to prevent gcc warning */
@@ -2959,7 +2959,7 @@ int charmap_encoding_error(
*inpos = collendpos;
break;
default:
- repunicode = unicode_encode_call_errorhandler(errors, &errorHandler,
+ repunicode = unicode_encode_call_errorhandler(errors, errorHandler,
encoding, reason, p, size, exceptionObject,
collstartpos, collendpos, &newpos);
if (repunicode == NULL)
@@ -3024,7 +3024,7 @@ PyObject *PyUnicode_EncodeCharmap(const Py_UNICODE *p,
if (x==Py_None) { /* unencodable character */
if (charmap_encoding_error(p, size, &inpos, mapping,
&exc,
- &known_errorHandler, errorHandler, errors,
+ &known_errorHandler, &errorHandler, errors,
&res, &respos))
goto onError;
}