pycredentials: Fix memory leak.
authorJelmer Vernooij <jelmer@samba.org>
Wed, 17 Jun 2009 17:00:31 +0000 (19:00 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 17 Jun 2009 18:45:38 +0000 (20:45 +0200)
source4/auth/credentials/pycredentials.c

index de5cc87194769a54f90c082ccd952d91375be57d..3b119555380d05278e2ed486629820d21751d60a 100644 (file)
@@ -38,7 +38,13 @@ static PyObject *PyString_FromStringOrNULL(const char *str)
 
 static PyObject *py_creds_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
 {
-       return py_talloc_import(type, cli_credentials_init(NULL));
+       py_talloc_Object *ret = (py_talloc_Object *)PyCredentials.tp_alloc(&PyCredentials, 0);
+       ret->talloc_ctx = talloc_new(NULL);
+       if (ret->talloc_ctx == NULL) {
+               return NULL;
+       }
+       ret->ptr = cli_credentials_init(ret->talloc_ctx);
+       return (PyObject *)ret;
 }
 
 static PyObject *py_creds_get_username(py_talloc_Object *self)