mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ruby_mimmalloc can return NULL
malloc can fail. Should treat such situations.
This commit is contained in:
parent
fb495b2928
commit
f5e4063272
3 changed files with 8 additions and 1 deletions
3
cont.c
3
cont.c
|
@ -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;
|
||||
|
|
4
gc.c
4
gc.c
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue