From: Florian Forster Date: Tue, 2 Sep 2014 17:48:10 +0000 (+0200) Subject: python plugin: Don't create empty meta_data_t objects. X-Git-Tag: collectd-5.3.2~47 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=0f4dc42a2a786763134d9661273608cfb2f52821;p=collectd.git python plugin: Don't create empty meta_data_t objects. Fixes: #716 --- diff --git a/src/pyvalues.c b/src/pyvalues.c index 4a658d06..4f5c4ce3 100644 --- a/src/pyvalues.c +++ b/src/pyvalues.c @@ -419,7 +419,7 @@ static meta_data_t *cpy_build_meta(PyObject *meta) { meta_data_t *m = NULL; PyObject *l; - if (!meta) + if ((meta == NULL) || (meta == Py_None)) return NULL; l = PyDict_Items(meta); /* New reference. */ @@ -427,8 +427,12 @@ static meta_data_t *cpy_build_meta(PyObject *meta) { cpy_log_exception("building meta data"); return NULL; } - m = meta_data_create(); + s = PyList_Size(l); + if (s < 0) + return NULL; + + m = meta_data_create(); for (i = 0; i < s; ++i) { const char *string, *keystring; PyObject *key, *value, *item, *tmp;