Diff of /Objects/bufferobject.c [278842] .. [5c26cf]  Maximize  Restore

Repo status: analyzing...

  Switch to side-by-side view

--- a/Objects/bufferobject.c
+++ b/Objects/bufferobject.c
@@ -167,6 +167,10 @@
 				"size must be zero or positive");
 		return NULL;
 	}
+	if (sizeof(*b) > INT_MAX - size) {
+		/* unlikely */
+		return PyErr_NoMemory();
+	}
 	/* Inline PyObject_New */
 	o = PyObject_MALLOC(sizeof(*b) + size);
 	if ( o == NULL )
@@ -354,6 +358,8 @@
 
 	if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 )
 		return NULL;
+
+	assert(count <= PY_SIZE_MAX - size);
 
  	ob = PyString_FromStringAndSize(NULL, size + count);
  	p = PyString_AS_STRING(ob);

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks