Code

plugin.c: Catch NULL-pointers and fix it or ignore the values.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 11 Feb 2007 11:39:22 +0000 (12:39 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 11 Feb 2007 11:39:22 +0000 (12:39 +0100)
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.

src/plugin.c

index 46a1c617129e957a79a28d6cfb7aec9440e5106a..d708b6bc8a6acc0ffecb47cf6575c8ab3ccaa611 100644 (file)
@@ -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