Commit cc06ea46 authored by Fred Drake's avatar Fred Drake

PyBuffer_New(): Raise ValueError if size is negative (the other

		 constructors didn't miss this).

		 Raise MemoryError if malloc() fails, instead of just
		 returning NULL.
parent ba6ad88f
...@@ -183,9 +183,14 @@ PyBuffer_New(size) ...@@ -183,9 +183,14 @@ PyBuffer_New(size)
{ {
PyBufferObject * b; PyBufferObject * b;
if (size < 0) {
PyErr_SetString(PyExc_ValueError,
"size must be zero or positive");
return NULL;
}
b = (PyBufferObject *)malloc(sizeof(*b) + size); b = (PyBufferObject *)malloc(sizeof(*b) + size);
if ( b == NULL ) if ( b == NULL )
return NULL; return PyErr_NoMemory();
b->ob_type = &PyBuffer_Type; b->ob_type = &PyBuffer_Type;
_Py_NewReference((PyObject *)b); _Py_NewReference((PyObject *)b);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment