unixsock: check return value of chmod
[collectd.git] / src / curl_xml.c
index e3d37f4..f0a1319 100644 (file)
@@ -696,7 +696,7 @@ static int cx_config_add_values (const char *name, cx_xpath_t *xpath, /* {{{ */
     sstrncpy (xpath->values[i].path, ci->values[i].value.string, sizeof (xpath->values[i].path));
   }
 
-  return (0); 
+  return (0);
 } /* }}} cx_config_add_values */
 
 static int cx_config_add_xpath (cx_t *db, /* {{{ */
@@ -726,6 +726,7 @@ static int cx_config_add_xpath (cx_t *db, /* {{{ */
   {
     ERROR ("curl_xml plugin: invalid xpath. "
            "xpath value can't be an empty string");
+    sfree (xpath);
     return (-1);
   }
 
@@ -769,6 +770,8 @@ static int cx_config_add_xpath (cx_t *db, /* {{{ */
       if (db->list == NULL)
       {
         ERROR ("curl_xml plugin: list creation failed.");
+        sfree (xpath->path);
+        sfree (xpath);
         return (-1);
       }
     }
@@ -777,6 +780,8 @@ static int cx_config_add_xpath (cx_t *db, /* {{{ */
     if (name == NULL)
     {
         ERROR ("curl_xml plugin: strdup failed.");
+        sfree (xpath->path);
+        sfree (xpath);
         return (-1);
     }
 
@@ -784,6 +789,8 @@ static int cx_config_add_xpath (cx_t *db, /* {{{ */
     if (le == NULL)
     {
       ERROR ("curl_xml plugin: llentry_create failed.");
+      sfree (xpath->path);
+      sfree (xpath);
       return (-1);
     }
 
@@ -919,6 +926,7 @@ static int cx_config_add_url (oconfig_item_t *ci) /* {{{ */
   {
     ERROR ("curl_xml plugin: cx_config: "
            "Invalid key: %s", ci->key);
+    cx_free (db);
     return (-1);
   }
 
@@ -975,7 +983,7 @@ static int cx_config_add_url (oconfig_item_t *ci) /* {{{ */
   if (status == 0)
   {
     user_data_t ud;
-    char cb_name[DATA_MAX_NAME_LEN];
+    char *cb_name;
 
     if (db->instance == NULL)
       db->instance = strdup("default");
@@ -987,11 +995,10 @@ static int cx_config_add_url (oconfig_item_t *ci) /* {{{ */
     ud.data = (void *) db;
     ud.free_func = cx_free;
 
-    ssnprintf (cb_name, sizeof (cb_name), "curl_xml-%s-%s",
-               db->instance, db->url);
-
-    plugin_register_complex_read (/* group = */ NULL, cb_name, cx_read,
+    cb_name = ssnprintf_alloc ("curl_xml-%s-%s", db->instance, db->url);
+    plugin_register_complex_read (/* group = */ "curl_xml", cb_name, cx_read,
                                   /* interval = */ NULL, &ud);
+    sfree (cb_name);
   }
   else
   {