on master help sign in
Merge pull request #1967 from Chobbes/gc_malloc

GC check allocation of new heap.

commit446d99d74a60e018c326dd0a973b5565f12a5048 authorEdwin Brady <edwin.brady@gmail.com> dateThu 19 Mar 2015, 18:08 (12 years ago) parentf4aaf01d6d07ff
1 file changed+8
rts/idris_gc.c+8
rts/idris_gc.c+8
@@ -115,6 +115,14 @@ void idris_gc(VM* vm) {
115115 char* newheap = malloc(vm->heap.size);
116116 char* oldheap = vm->heap.heap;
117117
118+ if (newheap == NULL) {
119+ fprintf(stderr,
120+ "GC ERROR: Unable to allocate new heap. Requested %zd bytes.\n",
121+ vm->heap.size);
122+
123+ exit(EXIT_FAILURE);
124+ }
125+
118126 vm->heap.heap = newheap;
119127#ifdef FORCE_ALIGNMENT
120128 if (((i_int)(vm->heap.heap)&1) == 1) {