[Python-checkins] r79639 - in python/trunk: Objects/fileobject.c Objects/unicodeobject.c Python/marshal.c
benjamin.peterson
python-checkins at python.org
Sat Apr 3 02:57:33 CEST 2010
Author: benjamin.peterson
Date: Sat Apr 3 02:57:33 2010
New Revision: 79639
Log:
more _PyString_Resize error checking
Modified:
python/trunk/Objects/fileobject.c
python/trunk/Objects/unicodeobject.c
python/trunk/Python/marshal.c
Modified: python/trunk/Objects/fileobject.c
==============================================================================
--- python/trunk/Objects/fileobject.c (original)
+++ python/trunk/Objects/fileobject.c Sat Apr 3 02:57:33 2010
@@ -1102,8 +1102,8 @@
break;
}
}
- if (bytesread != buffersize)
- _PyString_Resize(&v, bytesread);
+ if (bytesread != buffersize && _PyString_Resize(&v, bytesread))
+ return NULL;
return v;
}
@@ -1356,8 +1356,8 @@
/* overwrite the trailing null byte */
pvfree = BUF(v) + (prev_v_size - 1);
}
- if (BUF(v) + total_v_size != p)
- _PyString_Resize(&v, p - BUF(v));
+ if (BUF(v) + total_v_size != p && _PyString_Resize(&v, p - BUF(v)))
+ return NULL;
return v;
#undef INITBUFSIZE
#undef MAXBUFSIZE
@@ -1469,8 +1469,8 @@
}
used_v_size = buf - BUF(v);
- if (used_v_size != total_v_size)
- _PyString_Resize(&v, used_v_size);
+ if (used_v_size != total_v_size && _PyString_Resize(&v, used_v_size))
+ return NULL;
return v;
}
@@ -1536,8 +1536,10 @@
"EOF when reading a line");
}
else if (s[len-1] == '\n') {
- if (result->ob_refcnt == 1)
- _PyString_Resize(&result, len-1);
+ if (result->ob_refcnt == 1) {
+ if (_PyString_Resize(&result, len-1))
+ return NULL;
+ }
else {
PyObject *v;
v = PyString_FromStringAndSize(s, len-1);
Modified: python/trunk/Objects/unicodeobject.c
==============================================================================
--- python/trunk/Objects/unicodeobject.c (original)
+++ python/trunk/Objects/unicodeobject.c Sat Apr 3 02:57:33 2010
@@ -1848,7 +1848,8 @@
if (inShift)
*out++ = '-';
- _PyString_Resize(&v, out - start);
+ if (_PyString_Resize(&v, out - start))
+ return NULL;
return v;
}
@@ -2169,7 +2170,8 @@
/* Cut back to size actually needed. */
nneeded = p - PyString_AS_STRING(v);
assert(nneeded <= nallocated);
- _PyString_Resize(&v, nneeded);
+ if (_PyString_Resize(&v, nneeded))
+ return NULL;
}
return v;
@@ -3129,7 +3131,8 @@
*p++ = PyString_AS_STRING(repr)[1];
*p = '\0';
- _PyString_Resize(&repr, p - PyString_AS_STRING(repr));
+ if (_PyString_Resize(&repr, p - PyString_AS_STRING(repr)))
+ return NULL;
return repr;
}
@@ -3350,7 +3353,8 @@
*p++ = (char) ch;
}
*p = '\0';
- _PyString_Resize(&repr, p - q);
+ if (_PyString_Resize(&repr, p - q))
+ return NULL;
return repr;
}
Modified: python/trunk/Python/marshal.c
==============================================================================
--- python/trunk/Python/marshal.c (original)
+++ python/trunk/Python/marshal.c Sat Apr 3 02:57:33 2010
@@ -1237,7 +1237,8 @@
"too much marshall data for a string");
return NULL;
}
- _PyString_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base));
+ if (_PyString_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base)))
+ return NULL;
}
if (wf.error != WFERR_OK) {
Py_XDECREF(wf.str);
More information about the Python-checkins
mailing list