If python pugin reads and writes collectd values, the write python
plugin callback may crash (90%) on free table var (line 478) if the
meta data structure is created but no information is present there.
It's possible to reproduce it due to changes introduced by #2135 PR.
cpy_write_callback():
...
425 if (value_list->meta) {
426 char **table;
427 meta_data_t *meta = value_list->meta;
428
429 int num = meta_data_toc(meta, &table);
430 for (int i = 0; i < num; ++i) {
...
477 }
478 free(table);
479 }
Change-Id: Ic897933f447b9280f266b6e78b6b73bd12182eba
Signed-off-by: Mytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com>
}
dict = PyDict_New(); /* New reference. */
if (value_list->meta) {
- char **table;
+ char **table = NULL;
meta_data_t *meta = value_list->meta;
int num = meta_data_toc(meta, &table);
static meta_data_t *cpy_build_value_meta(PyObject *meta) {
meta_data_t *m = meta_data_create();
- cpy_build_meta(meta, &cpy_meta_data, (void *)m);
+ if (cpy_build_meta(meta, &cpy_meta_data, (void *)m) < 0) {
+ meta_data_destroy(m);
+ return NULL;
+ }
return m;
}