Code

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 c391e6937579f52c067cd98fcc9c15e59232abfb..16a21e65a991825d98873c7d4ae4ff4307e77349 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);
 
+  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);