From 6496d94f157af17ccf0f9cf3dee67c663a23313b Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Sun, 30 Aug 2009 16:29:52 -0300 Subject: [PATCH] Make realloc() handle null as a malloc() result --- gc/gc.d | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gc/gc.d b/gc/gc.d index f0471de..7d33622 100644 --- a/gc/gc.d +++ b/gc/gc.d @@ -604,8 +604,11 @@ public: // We need to move the cell because of the lack of capacity, find // a free cell with the requested capacity (at least) - Cell* new_cell = Cell.from_ptr(this.malloc(size)); - assert (!(new_cell is null)); // out of memory is handled by malloc() + ptr = this.malloc(size, attr); + if (ptr is null) // in case onOutOfMemoryError didn't throw + return null; + Cell* new_cell = Cell.from_ptr(ptr); + assert (new_cell !is null); // Move cell attributes and contents new_cell.attr = cell.attr; -- 2.43.0