[Python-checkins] r46234 - python/trunk/Objects/stringobject.c
andrew.dalke
python-checkins at python.org
Thu May 25 20:18:39 CEST 2006
Author: andrew.dalke
Date: Thu May 25 20:18:39 2006
New Revision: 46234
Modified:
python/trunk/Objects/stringobject.c
Log:
Added overflow test for adding two (very) large strings where the
new string is over max Py_ssize_t. I have no way to test it on my
box or any box I have access to. At least it doesn't break anything.
Modified: python/trunk/Objects/stringobject.c
==============================================================================
--- python/trunk/Objects/stringobject.c (original)
+++ python/trunk/Objects/stringobject.c Thu May 25 20:18:39 2006
@@ -1023,7 +1023,7 @@
static PyObject *
string_concat(register PyStringObject *a, register PyObject *bb)
{
- register size_t size;
+ register Py_ssize_t size;
register PyStringObject *op;
if (!PyString_Check(bb)) {
#ifdef Py_USING_UNICODE
@@ -1047,7 +1047,12 @@
return (PyObject *)a;
}
size = a->ob_size + b->ob_size;
- /* XXX check overflow */
+ if (size < 0) {
+ PyErr_SetString(PyExc_OverflowError,
+ "strings are too large to concat");
+ return NULL;
+ }
+
/* Inline PyObject_NewVar */
op = (PyStringObject *)PyObject_MALLOC(sizeof(PyStringObject) + size);
if (op == NULL)
More information about the Python-checkins
mailing list