diff options
-rw-r--r-- | cont.c | 3 | ||||
-rw-r--r-- | gc.c | 4 | ||||
-rw-r--r-- | internal.h | 2 |
3 files changed, 8 insertions, 1 deletions
@@ -1865,6 +1865,9 @@ void rb_threadptr_root_fiber_setup(rb_thread_t *th) { rb_fiber_t *fiber = ruby_mimmalloc(sizeof(rb_fiber_t)); + if (!fiber) { + rb_bug("%s", strerror(errno)); /* ... is it possible to call rb_bug here? */ + } MEMZERO(fiber, rb_fiber_t, 1); fiber->cont.type = FIBER_CONTEXT; fiber->cont.saved_ec.fiber_ptr = fiber; @@ -10301,6 +10301,10 @@ ruby_mimmalloc(size_t size) #endif mem = malloc(size); #if CALC_EXACT_MALLOC_SIZE + if (!mem) { + return NULL; + } + else /* set 0 for consistency of allocated_size/allocations */ { struct malloc_obj_info *info = mem; diff --git a/internal.h b/internal.h index 5b9b9b62bc..c10bac5358 100644 --- a/internal.h +++ b/internal.h @@ -1606,7 +1606,7 @@ NORETURN(void rb_syserr_fail_path_in(const char *func_name, int err, VALUE path) extern VALUE *ruby_initial_gc_stress_ptr; extern int ruby_disable_gc; void Init_heap(void); -void *ruby_mimmalloc(size_t size); +void *ruby_mimmalloc(size_t size) RUBY_ATTR_MALLOC; void ruby_mimfree(void *ptr); void rb_objspace_set_event_hook(const rb_event_flag_t event); #if USE_RGENGC |