[Python-checkins] python/dist/src/Objects unicodeobject.c, 2.190, 2.191

doerwalter at users.sourceforge.net doerwalter at users.sourceforge.net
Thu Aug 14 14:25:31 EDT 2003


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv1205/Objects

Modified Files:
	unicodeobject.c 
Log Message:
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().


Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.190
retrieving revision 2.191
diff -C2 -d -r2.190 -r2.191
*** unicodeobject.c	1 Jul 2003 00:13:27 -0000	2.190
--- unicodeobject.c	14 Aug 2003 20:25:29 -0000	2.191
***************
*** 2877,2881 ****
      const Py_UNICODE *p, int size, int *inpos, PyObject *mapping,
      PyObject **exceptionObject,
!     int *known_errorHandler, PyObject *errorHandler, const char *errors,
      PyObject **res, int *respos)
  {
--- 2877,2881 ----
      const Py_UNICODE *p, int size, int *inpos, PyObject *mapping,
      PyObject **exceptionObject,
!     int *known_errorHandler, PyObject **errorHandler, const char *errors,
      PyObject **res, int *respos)
  {
***************
*** 2960,2964 ****
  	    break;
  	default:
! 	    repunicode = unicode_encode_call_errorhandler(errors, &errorHandler,
  		encoding, reason, p, size, exceptionObject,
  		collstartpos, collendpos, &newpos);
--- 2960,2964 ----
  	    break;
  	default:
! 	    repunicode = unicode_encode_call_errorhandler(errors, errorHandler,
  		encoding, reason, p, size, exceptionObject,
  		collstartpos, collendpos, &newpos);
***************
*** 3025,3029 ****
  	    if (charmap_encoding_error(p, size, &inpos, mapping,
  		&exc,
! 		&known_errorHandler, errorHandler, errors,
  		&res, &respos))
  		goto onError;
--- 3025,3029 ----
  	    if (charmap_encoding_error(p, size, &inpos, mapping,
  		&exc,
! 		&known_errorHandler, &errorHandler, errors,
  		&res, &respos))
  		goto onError;





More information about the Python-checkins mailing list