summaryrefslogtreecommitdiffstats
path: root/Objects/bufferobject.c
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-08-04 13:08:19 (GMT)
committerFred Drake <fdrake@acm.org>1999-08-04 13:08:19 (GMT)
commit4574f23115e2c0b35a2e1a4cac0aa7c855144639 (patch)
treed8a2dd3a779b17185a556865306270ef596400a0 /Objects/bufferobject.c
parent493aa4809b787bf6677b241a2e8e2c023b6a0710 (diff)
downloadcpython-4574f23115e2c0b35a2e1a4cac0aa7c855144639.zip
cpython-4574f23115e2c0b35a2e1a4cac0aa7c855144639.tar.gz
cpython-4574f23115e2c0b35a2e1a4cac0aa7c855144639.tar.bz2
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.
Diffstat (limited to 'Objects/bufferobject.c')
-rw-r--r--Objects/bufferobject.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/bufferobject.c b/Objects/bufferobject.c
index 017ae64..05b1f11 100644
--- a/Objects/bufferobject.c
+++ b/Objects/bufferobject.c
@@ -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);