Merge branch 'master' of git://git.denx.de/u-boot-blackfin
[platform/kernel/u-boot.git] / common / dlmalloc.c
index 735b344..2276532 100644 (file)
@@ -1515,7 +1515,7 @@ void *sbrk(ptrdiff_t increment)
        ulong new = old + increment;
 
        if ((new < mem_malloc_start) || (new > mem_malloc_end))
-               return NULL;
+               return (void *)MORECORE_FAILURE;
 
        mem_malloc_brk = new;
 
@@ -2179,6 +2179,12 @@ Void_t* mALLOc(bytes) size_t bytes;
 
   INTERNAL_SIZE_T nb;
 
+  /* check if mem_malloc_init() was run */
+  if ((mem_malloc_start == 0) && (mem_malloc_end == 0)) {
+    /* not initialized yet */
+    return 0;
+  }
+
   if ((long)bytes < 0) return 0;
 
   nb = request2size(bytes);  /* padded request size; */