From: Florian Forster Date: Tue, 8 Dec 2015 12:44:28 +0000 (+0100) Subject: python plugin: Check return value of malloc(). X-Git-Tag: collectd-5.5.1~13^2~9 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=acee3e5ef13384b24d83da25a12f72e4e32c60ab;p=collectd.git python plugin: Check return value of malloc(). CID: 37981, 37982, 37983 --- 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;