mtd: sf: Make sf_mtd.c more robust
[platform/kernel/u-boot.git] / common / malloc_simple.c
index 6114002..871b544 100644 (file)
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Simple malloc implementation
  *
  * Copyright (c) 2014 Google, Inc
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -58,7 +57,8 @@ void *calloc(size_t nmemb, size_t elem_size)
        void *ptr;
 
        ptr = malloc(size);
-       memset(ptr, '\0', size);
+       if (ptr)
+               memset(ptr, '\0', size);
 
        return ptr;
 }