return NULL for a zero size memdup
authorAndrew Tridgell <tridge@samba.org>
Sat, 22 Apr 2000 08:29:41 +0000 (08:29 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sat, 22 Apr 2000 08:29:41 +0000 (08:29 +0000)
source/lib/util.c

index 2f8b52ccbde28eda156ddf124ddfac3ccb26ec45..ccdfc72bbdd6dcd71617d8f44814452360105582 100644 (file)
@@ -2581,6 +2581,7 @@ like strdup but for memory
 void *memdup(void *p, size_t size)
 {
        void *p2;
+       if (size == 0) return NULL;
        p2 = malloc(size);
        if (!p2) return NULL;
        memcpy(p2, p, size);