snmp plugin: initialize res sooner
[collectd.git] / src / write_kafka.c
index 9bc958f..37b3e14 100644 (file)
@@ -114,7 +114,7 @@ static int kafka_handle(struct kafka_topic_context *ctx) /* {{{ */
 
         INFO ("write_kafka plugin: created KAFKA handle : %s", rd_kafka_name(ctx->kafka));
 
-#ifdef HAVE_LIBRDKAFKA_LOGGER
+#if defined(HAVE_LIBRDKAFKA_LOGGER) && !defined(HAVE_LIBRDKAFKA_LOG_CB)
         rd_kafka_set_logger(ctx->kafka, kafka_log);
 #endif
     }
@@ -437,12 +437,15 @@ static int kafka_config(oconfig_item_t *ci) /* {{{ */
             }
             if ((val = strdup(child->values[1].value.string)) == NULL) {
                 WARNING("cannot allocate memory for attribute value.");
+                sfree(key);
                 goto errout;
             }
             ret = rd_kafka_conf_set(conf, key, val, errbuf, sizeof(errbuf));
             if (ret != RD_KAFKA_CONF_OK) {
                 WARNING("cannot set kafka property %s to %s: %s",
                         key, val, errbuf);
+                sfree(key);
+                sfree(val);
                 goto errout;
             }
             sfree(key);
@@ -466,4 +469,3 @@ void module_register(void)
 {
     plugin_register_complex_config ("write_kafka", kafka_config);
 }
-