write_http: Added strdup() result check
authorPavel Rochnyack <pavel2000@ngs.ru>
Mon, 16 Oct 2017 12:05:20 +0000 (19:05 +0700)
committerPavel Rochnyack <pavel2000@ngs.ru>
Mon, 16 Oct 2017 12:05:20 +0000 (19:05 +0700)
src/write_http.c

index c391e69..16a21e6 100644 (file)
@@ -637,6 +637,12 @@ static int wh_config_node(oconfig_item_t *ci) /* {{{ */
   cb->data_ttl = 0;
   cb->metrics_prefix = strdup(WRITE_HTTP_DEFAULT_PREFIX);
 
   cb->data_ttl = 0;
   cb->metrics_prefix = strdup(WRITE_HTTP_DEFAULT_PREFIX);
 
+  if (cb->metrics_prefix == NULL) {
+    ERROR("write_http plugin: strdup failed.");
+    sfree(cb);
+    return -1;
+  }
+
   pthread_mutex_init(&cb->send_lock, /* attr = */ NULL);
 
   cf_util_get_string(ci, &cb->name);
   pthread_mutex_init(&cb->send_lock, /* attr = */ NULL);
 
   cf_util_get_string(ci, &cb->name);