gauge_t *values;
size_t values_num;
+ char *identifier_copy;
+
const data_set_t *ds;
int status;
if (strlen (fields[1]) < strlen ("h/p/t"))
{
- fprintf (fh, "-1 Invalied identifier, %s", fields[1]);
+ fprintf (fh, "-1 Invalied identifier, %s\n", fields[1]);
fflush (fh);
return (-1);
}
- status = parse_identifier (fields[1], &hostname,
+ /* parse_identifier() modifies its first argument,
+ * returning pointers into it */
+ identifier_copy = sstrdup (fields[1]);
+
+ status = parse_identifier (identifier_copy, &hostname,
&plugin, &plugin_instance,
&type, &type_instance);
if (status != 0)
DEBUG ("unixsock plugin: Cannot parse `%s'", fields[1]);
fprintf (fh, "-1 Cannot parse identifier.\n");
fflush (fh);
+ sfree (identifier_copy);
return (-1);
}
DEBUG ("unixsock plugin: plugin_get_ds (%s) == NULL;", type);
fprintf (fh, "-1 Type `%s' is unknown.\n", type);
fflush (fh);
+ sfree (identifier_copy);
return (-1);
}
status = uc_get_rate_by_name (fields[1], &values, &values_num);
if (status != 0)
{
- fprintf (fh, "-1 No such value");
+ fprintf (fh, "-1 No such value\n");
fflush (fh);
+ sfree (identifier_copy);
return (-1);
}
fprintf (fh, "-1 Error reading value from cache.\n");
fflush (fh);
sfree (values);
+ sfree (identifier_copy);
return (-1);
}
fflush (fh);
sfree (values);
+ sfree (identifier_copy);
return (0);
} /* int handle_getval */