From: Leandro Lucarella Date: Sun, 30 Aug 2009 19:29:52 +0000 (-0300) Subject: Make realloc() handle null as a malloc() result X-Git-Tag: word-sized-cells~3 X-Git-Url: https://git.llucax.com/software/dgc/naive.git/commitdiff_plain/6496d94f157af17ccf0f9cf3dee67c663a23313b?ds=sidebyside Make realloc() handle null as a malloc() result --- 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;