Add harmless parentheses so that dmalloc doesn't get confused by a
[ira/wip.git] / source3 / lib / util.c
index 63939e0ecfa4e6df631f525abe5486fb4ad1c0ca..6caa605066367e5ffef7713dfa833e36ef660f6d 100644 (file)
@@ -2098,17 +2098,22 @@ static void free_data_blob(DATA_BLOB *d)
 
 /*******************************************************************
  construct a data blob, must be freed with data_blob_free()
+ you can pass NULL for p and get a blank data blob
 *******************************************************************/
 DATA_BLOB data_blob(const void *p, size_t length)
 {
        DATA_BLOB ret;
 
-       if (!p || !length) {
+       if (!length) {
                ZERO_STRUCT(ret);
                return ret;
        }
 
-       ret.data = smb_xmemdup(p, length);
+       if (p) {
+               ret.data = smb_xmemdup(p, length);
+       } else {
+               ret.data = smb_xmalloc(length);
+       }
        ret.length = length;
        ret.free = free_data_blob;
        return ret;
@@ -2142,7 +2147,7 @@ void data_blob_free(DATA_BLOB *d)
 {
        if (d) {
                if (d->free) {
-                       d->free(d);
+                       (d->free)(d);
                }
                ZERO_STRUCTP(d);
        }