[Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.57,2.58
M.-A. Lemburg
python-dev@python.org
Mon, 14 Aug 2000 04:29:23 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory slayer.i.sourceforge.net:/tmp/cvs-serv22589/Objects
Modified Files:
unicodeobject.c
Log Message:
Fixed a couple of instances where a 0-length string was being
resized after creation. 0-length strings are usually shared
and _PyString_Resize() fails on these shared strings.
Fixes [ Bug #111667 ] unicode core dump.
Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.57
retrieving revision 2.58
diff -C2 -r2.57 -r2.58
*** unicodeobject.c 2000/08/12 22:14:34 2.57
--- unicodeobject.c 2000/08/14 11:29:19 2.58
***************
*** 843,847 ****
return NULL;
if (size == 0)
! goto done;
p = q = PyString_AS_STRING(v);
--- 843,847 ----
return NULL;
if (size == 0)
! return v;
p = q = PyString_AS_STRING(v);
***************
*** 893,898 ****
if (_PyString_Resize(&v, p - q))
goto onError;
-
- done:
return v;
--- 893,896 ----
***************
*** 1083,1087 ****
*p++ = 0xFEFF;
if (size == 0)
! goto done;
if (byteorder == 0 ||
#ifdef BYTEORDER_IS_LITTLE_ENDIAN
--- 1081,1085 ----
*p++ = 0xFEFF;
if (size == 0)
! return v;
if (byteorder == 0 ||
#ifdef BYTEORDER_IS_LITTLE_ENDIAN
***************
*** 1097,1101 ****
*p++ = (ch >> 8) | (ch << 8);
}
- done:
return v;
}
--- 1095,1098 ----
***************
*** 1564,1567 ****
--- 1561,1566 ----
if (repr == NULL)
return NULL;
+ if (size == 0)
+ return repr;
p = q = PyString_AS_STRING(repr);
***************
*** 1663,1669 ****
--- 1662,1671 ----
PyObject *repr;
char *s, *start;
+
repr = PyString_FromStringAndSize(NULL, size);
if (repr == NULL)
return NULL;
+ if (size == 0)
+ return repr;
s = PyString_AS_STRING(repr);
***************
*** 1803,1809 ****
--- 1805,1814 ----
PyObject *repr;
char *s, *start;
+
repr = PyString_FromStringAndSize(NULL, size);
if (repr == NULL)
return NULL;
+ if (size == 0)
+ return repr;
s = PyString_AS_STRING(repr);
***************
*** 1891,1895 ****
if (repr == NULL)
return NULL;
! if (mbcssize==0)
return repr;
--- 1896,1900 ----
if (repr == NULL)
return NULL;
! if (mbcssize == 0)
return repr;
***************
*** 2068,2071 ****
--- 2073,2078 ----
if (v == NULL)
return NULL;
+ if (size == 0)
+ return v;
s = PyString_AS_STRING(v);
while (size-- > 0) {