From 7b8fcacda29954c585746c255598b9b180e56e1f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 17 Jun 2009 19:07:22 +0200 Subject: pycredentials: Raise MemoryError when unable to create objects. --- source4/auth/credentials/pycredentials.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source4/auth/credentials/pycredentials.c') diff --git a/source4/auth/credentials/pycredentials.c b/source4/auth/credentials/pycredentials.c index 3b11955538..b0433abeab 100644 --- a/source4/auth/credentials/pycredentials.c +++ b/source4/auth/credentials/pycredentials.c @@ -38,9 +38,14 @@ static PyObject *PyString_FromStringOrNULL(const char *str) static PyObject *py_creds_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { - py_talloc_Object *ret = (py_talloc_Object *)PyCredentials.tp_alloc(&PyCredentials, 0); + py_talloc_Object *ret = (py_talloc_Object *)type->tp_alloc(type, 0); + if (ret == NULL) { + PyErr_NoMemory(); + return NULL; + } ret->talloc_ctx = talloc_new(NULL); if (ret->talloc_ctx == NULL) { + PyErr_NoMemory(); return NULL; } ret->ptr = cli_credentials_init(ret->talloc_ctx); -- cgit