From: Alberto Bertogli Date: Fri, 15 May 2009 02:18:09 +0000 (-0300) Subject: Initialize capacity to 0 when allocating a new cell X-Git-Tag: word-sized-cells~5 X-Git-Url: https://git.llucax.com/software/dgc/naive.git/commitdiff_plain/2d8639409b4749afd92266347f20b99da80e14c9?hp=1510e826d84ca402a00c5cab2d2e2d172b8602d2 Initialize capacity to 0 when allocating a new cell Otherwise, when later we do cell.capacity == 0 we're using uninitialized memory and can return the wrong result if we're not lucky enough to get 0s. --- diff --git a/gc/gc.d b/gc/gc.d index 3ee81ac..a7c8f59 100644 --- a/gc/gc.d +++ b/gc/gc.d @@ -533,6 +533,7 @@ public: // No luck still, allocate new memory cell = cast(Cell*) cstdlib.malloc(size + Cell.sizeof); + cell.capacity = 0; // so we can later tell it's new if (cell) goto success;