chiark / gitweb /
bus: generate a nice error when attempting to add a NULL string
[elogind.git] / src / libsystemd-bus / bus-message.c
index c0a0242fd612dfd7b2ce2e082f0ebaa069abb20e..524f17eb9f952707ebdbc91da3c98121a4c14e1c 100644 (file)
@@ -768,11 +768,27 @@ int message_append_basic(sd_bus_message *m, char type, const void *p, const void
 
         case SD_BUS_TYPE_STRING:
         case SD_BUS_TYPE_OBJECT_PATH:
 
         case SD_BUS_TYPE_STRING:
         case SD_BUS_TYPE_OBJECT_PATH:
+
+                if (!p) {
+                        if (e)
+                                c->signature[c->index] = 0;
+
+                        return -EINVAL;
+                }
+
                 align = 4;
                 sz = 4 + strlen(p) + 1;
                 break;
 
         case SD_BUS_TYPE_SIGNATURE:
                 align = 4;
                 sz = 4 + strlen(p) + 1;
                 break;
 
         case SD_BUS_TYPE_SIGNATURE:
+
+                if (!p) {
+                        if (e)
+                                c->signature[c->index] = 0;
+
+                        return -EINVAL;
+                }
+
                 align = 1;
                 sz = 1 + strlen(p) + 1;
                 break;
                 align = 1;
                 sz = 1 + strlen(p) + 1;
                 break;