[Python-checkins] python/dist/src/Objects stringobject.c,2.186,2.187

doerwalter@users.sourceforge.net doerwalter@users.sourceforge.net
2002年9月03日 06:53:43 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv21090/Objects
Modified Files:
	stringobject.c 
Log Message:
Check whether a string resize is necessary at the end
of PyString_DecodeEscape(). This prevents a call to
_PyString_Resize() for the empty string, which would
result in a PyErr_BadInternalCall(), because the
empty string has more than one reference.
This closes SF bug http://www.python.org/sf/603937
Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.186
retrieving revision 2.187
diff -C2 -d -r2.186 -r2.187
*** stringobject.c	2 Sep 2002 13:14:31 -0000	2.186
--- stringobject.c	3 Sep 2002 13:53:40 -0000	2.187
***************
*** 534,539 ****
 	const char *end;
 	PyObject *v;
! 	v = PyString_FromStringAndSize((char *)NULL, 
! 				 recode_encoding ? 4*len:len);
 	if (v == NULL)
 		return NULL;
--- 534,539 ----
 	const char *end;
 	PyObject *v;
! 	int newlen = recode_encoding ? 4*len:len;
! 	v = PyString_FromStringAndSize((char *)NULL, newlen);
 	if (v == NULL)
 		return NULL;
***************
*** 661,665 ****
 		}
 	}
! 	_PyString_Resize(&v, (int)(p - buf));
 	return v;
 failed:
--- 661,666 ----
 		}
 	}
! 	if (p-buf < newlen)
! 		_PyString_Resize(&v, (int)(p - buf));
 	return v;
 failed:

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