diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2010-01-21 16:44:12 +1300 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2010-01-21 16:44:12 +1300 |
commit | 253a232d300ac6a508983bbbb6eb6d0235d48722 (patch) | |
tree | b41ed757b251f682c220bc38298f1cecec27a524 /source4/scripting/python/pyxattr_native.c | |
parent | 9a253808383e1a2777c3c05a25be88ed25c51a13 (diff) | |
download | samba-253a232d300ac6a508983bbbb6eb6d0235d48722.tar.gz samba-253a232d300ac6a508983bbbb6eb6d0235d48722.tar.bz2 samba-253a232d300ac6a508983bbbb6eb6d0235d48722.zip |
pyxattr: Fix memory leaks.
Diffstat (limited to 'source4/scripting/python/pyxattr_native.c')
-rw-r--r-- | source4/scripting/python/pyxattr_native.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source4/scripting/python/pyxattr_native.c b/source4/scripting/python/pyxattr_native.c index 70fdf571f1..9b60039a38 100644 --- a/source4/scripting/python/pyxattr_native.c +++ b/source4/scripting/python/pyxattr_native.c @@ -35,6 +35,7 @@ static PyObject *py_is_xattr_supported(PyObject *self) return Py_True; #endif } + static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args) { char *filename, *attribute; @@ -42,11 +43,12 @@ static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args) int blobsize; DATA_BLOB blob; - if (!PyArg_ParseTuple(args, "sss#", &filename,&attribute,&blob.data,&blobsize)) + if (!PyArg_ParseTuple(args, "sss#", &filename, &attribute, &blob.data, + &blobsize)) return NULL; blob.length = blobsize; - ret = wrap_setxattr(filename,attribute,blob.data,blob.length,0); + ret = wrap_setxattr(filename, attribute, blob.data, blob.length, 0); if( ret < 0 ) { if (errno == ENOTSUP) { PyErr_SetFromErrno(PyExc_IOError); @@ -65,7 +67,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args) TALLOC_CTX *mem_ctx; char *buf; PyObject *ret; - if (!PyArg_ParseTuple(args, "ss", &filename,&attribute)) + if (!PyArg_ParseTuple(args, "ss", &filename, &attribute)) return NULL; mem_ctx = talloc_new(NULL); len = wrap_getxattr(filename,attribute,NULL,0); @@ -75,6 +77,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args) } else { PyErr_SetFromErrno(PyExc_TypeError); } + talloc_free(mem_ctx); return NULL; } /* check length ... */ @@ -86,10 +89,11 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args) } else { PyErr_SetFromErrno(PyExc_TypeError); } + talloc_free(mem_ctx); return NULL; } ret = PyString_FromStringAndSize(buf, len); - talloc_free(buf); + talloc_free(mem_ctx); return ret; } |