aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-11-01 15:56:02 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-11-01 16:58:19 +0900
commitf5e406327200672f95d61c4ca4ffc9de03e6a5a7 (patch)
treeeee27880c3ffd7fb2a433058ef75f2acdad96235 /gc.c
parentfb495b2928545e44cc9859f7cc743032d92ca9ee (diff)
downloadruby-f5e406327200672f95d61c4ca4ffc9de03e6a5a7.tar.gz
ruby_mimmalloc can return NULL
malloc can fail. Should treat such situations.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index 97133e6a23..7365b6d6ec 100644
--- a/gc.c
+++ b/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;