From acee3e5ef13384b24d83da25a12f72e4e32c60ab Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 8 Dec 2015 13:44:28 +0100 Subject: [PATCH] python plugin: Check return value of malloc(). CID: 37981, 37982, 37983 --- src/python.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/python.c b/src/python.c index 6a65ff25..10d283d9 100644 --- a/src/python.c +++ b/src/python.c @@ -534,7 +534,12 @@ static PyObject *cpy_register_generic(cpy_callback_t **list_head, PyObject *args Py_INCREF(callback); Py_XINCREF(data); + c = malloc(sizeof(*c)); + if (c == NULL) + return NULL; + memset (c, 0, sizeof (*c)); + c->name = strdup(buf); c->callback = callback; c->data = data; @@ -589,7 +594,12 @@ static PyObject *cpy_register_generic_userdata(void *reg, void *handler, PyObjec Py_INCREF(callback); Py_XINCREF(data); + c = malloc(sizeof(*c)); + if (c == NULL) + return NULL; + memset (c, 0, sizeof (*c)); + c->name = strdup(buf); c->callback = callback; c->data = data; @@ -624,7 +634,12 @@ static PyObject *cpy_register_read(PyObject *self, PyObject *args, PyObject *kwd Py_INCREF(callback); Py_XINCREF(data); + c = malloc(sizeof(*c)); + if (c == NULL) + return NULL; + memset (c, 0, sizeof (*c)); + c->name = strdup(buf); c->callback = callback; c->data = data; -- 2.30.2