From: Florian Forster Date: Sun, 11 Feb 2007 11:39:22 +0000 (+0100) Subject: plugin.c: Catch NULL-pointers and fix it or ignore the values. X-Git-Tag: collectd-3.11.2~2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6b3bcf8fdba6115766d7cb170ff5328038c7383c;p=collectd.git plugin.c: Catch NULL-pointers and fix it or ignore the values. Some systems, such as Solaris, cannot handle NULL-pointers being passed to `printf ("%s", NULL);' or the like. This caused a crash when sending the users plugin's values over the network under Solaris. --- diff --git a/src/plugin.c b/src/plugin.c index 46a1c617..d708b6bc 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -375,6 +375,18 @@ void plugin_write (char *host, char *type, char *inst, char *val) */ void plugin_submit (char *type, char *inst, char *val) { + if (inst == NULL) + inst = "-"; + + if ((type == NULL) || (val == NULL)) + { + DBG ("Help! NULL-pointer! type = %s; inst = %s; val = %s;", + (type == NULL) ? "(null)" : type, + inst, + (val == NULL) ? "(null)" : val); + return; + } + if (operating_mode == MODE_CLIENT) network_send (type, inst, val); else