metadata: allow NULL pointers in kdbus_meta_append_data()
authorDaniel Mack <zonque@gmail.com>
Fri, 15 Aug 2014 17:46:10 +0000 (19:46 +0200)
committerDaniel Mack <zonque@gmail.com>
Fri, 15 Aug 2014 20:11:03 +0000 (22:11 +0200)
Allow NULL pointers to be passed as data argument to
kdbus_meta_append_data(), so users can use the function to only make space
in the metadata without actually copying any payload.

metadata.c

index 267bb4918cacac3977eae11448b1421f7d1cf4e9..b2b27e614916561c4cea739149fa424e391532ba 100644 (file)
@@ -162,7 +162,8 @@ int kdbus_meta_append_data(struct kdbus_meta *meta, u64 type,
 
        item->type = type;
        item->size = KDBUS_ITEM_HEADER_SIZE + len;
-       memcpy(item->data, data, len);
+       if (data)
+               memcpy(item->data, data, len);
 
        return 0;
 }