Kaydet (Commit) 4574f231 authored tarafından 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.
üst 493aa480
......@@ -183,9 +183,14 @@ PyBuffer_New(size)
{
PyBufferObject * b;
if (size < 0) {
PyErr_SetString(PyExc_ValueError,
"size must be zero or positive");
return NULL;
}
b = (PyBufferObject *)malloc(sizeof(*b) + size);
if ( b == NULL )
return NULL;
return PyErr_NoMemory();
b->ob_type = &PyBuffer_Type;
_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