Browse Source

lib: treat realloc of null pointer as alloc Now use zalloc rather than alloc with null. Fixes issue seen in bgp check tests.

Signed-off-by: Lou Berger <lberger@labn.net>
Lou Berger 4 years ago
parent
commit
9248b61f54
1 changed files with 3 additions and 0 deletions
  1. 3 0
      lib/memory.c

+ 3 - 0
lib/memory.c

@@ -108,6 +108,9 @@ zrealloc (int type, void *ptr, size_t size)
 {
   void *memory;
 
+  if (ptr == NULL)              /* is really alloc */
+      return zcalloc(type, size);
+
   memory = realloc (ptr, size);
   if (memory == NULL)
     zerror ("realloc", type, size);