From: Vincent Bernat Date: Mon, 3 Aug 2015 08:06:30 +0000 (+0200) Subject: logstash: initialize conf struct to 0 X-Git-Tag: collectd-5.5.1~72 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a9b65b73fc54f48b6f3633efa1a6c89f78a148bf;p=collectd.git logstash: initialize conf struct to 0 With YAJL 1 (at least on Ubuntu Precise), if `conf.indentString` is not initialized correctly, we would get a segfault even when `conf.beautify` is set to 0. We avoid this case by initializing the whole structure to 0. `conf.beautify = 0` is kept for explicitness. --- diff --git a/src/log_logstash.c b/src/log_logstash.c index 61e7f484..2883e6c9 100644 --- a/src/log_logstash.c +++ b/src/log_logstash.c @@ -208,7 +208,7 @@ static void log_logstash_log (int severity, const char *msg, { yajl_gen g; #if !defined(HAVE_YAJL_V2) - yajl_gen_config conf; + yajl_gen_config conf = {}; conf.beautify = 0; #endif @@ -252,7 +252,7 @@ static int log_logstash_notification (const notification_t *n, #if HAVE_YAJL_V2 g = yajl_gen_alloc(NULL); #else - yajl_gen_config conf; + yajl_gen_config conf = {}; conf.beautify = 0; g = yajl_gen_alloc(&conf, NULL);