diff options
author | Alex Plotnick <shrike@netaxs.com> | 2012-02-29 11:59:56 -0500 |
---|---|---|
committer | Julien Danjou <julien@danjou.info> | 2012-03-09 15:33:06 +0100 |
commit | 3ef6cfd18e57bd7b815c02bd9a52b3baf7a4858f (patch) | |
tree | aa3ec6f69391c3ec6bf6163099db76501184f2b8 | |
parent | 7ce51a20d9c95c982163ae340a4dff99dc5f05a6 (diff) |
Don't leak reply data.
Signed-off-by: Julien Danjou <julien@danjou.info>
-rw-r--r-- | src/cookie.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cookie.c b/src/cookie.c index 3a9f70b..ae7825d 100644 --- a/src/cookie.c +++ b/src/cookie.c @@ -67,6 +67,8 @@ xpybCookie_reply(xpybCookie *self, PyObject *args) xcb_generic_error_t *error; xcb_generic_reply_t *data; PyObject *shim, *reply; + void *buf; + Py_ssize_t len; /* Check arguments and connection. */ if (self->request->is_void) { @@ -86,14 +88,21 @@ xpybCookie_reply(xpybCookie *self, PyObject *args) } /* Create a shim protocol object */ - shim = PyBuffer_FromMemory(data, 32 + data->length * 4); + shim = PyBuffer_New(32 + data->length * 4); if (shim == NULL) goto err1; + if (PyObject_AsWriteBuffer(shim, &buf, &len) < 0) + goto err2; + memcpy(buf, data, len); + free(data); /* Call the reply type object to get a new xcb.Reply instance */ reply = PyObject_CallFunctionObjArgs((PyObject *)self->reply_type, shim, NULL); Py_DECREF(shim); return reply; + +err2: + Py_DECREF(shim); err1: free(data); return NULL; |