summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author卜部昌平 <[email protected]>2019-11-01 15:56:02 +0900
committer卜部昌平 <[email protected]>2019-11-01 16:58:19 +0900
commitf5e406327200672f95d61c4ca4ffc9de03e6a5a7 ()
treeeee27880c3ffd7fb2a433058ef75f2acdad96235
parentfb495b2928545e44cc9859f7cc743032d92ca9ee (diff)
ruby_mimmalloc can return NULL
malloc can fail. Should treat such situations.
-rw-r--r--cont.c3
-rw-r--r--gc.c4
-rw-r--r--internal.h2
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));
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
/* set 0 for consistency of allocated_size/allocations */
{
struct malloc_obj_info *info = mem;
@@ -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_mimfree(void *ptr);
void rb_objspace_set_event_hook(const rb_event_flag_t event);
#if USE_RGENGC