aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-08 17:52:38 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-08 17:52:38 +0000
commitb3935f179b3a5668320eab59a07e4de7b747546d (patch)
tree24d96826c2e0f47497f8f45df33121c17b5bc6b7 /gc.c
parent6db71fb11af4e3f1a79678f6dec6b2c10d012eff (diff)
downloadruby-b3935f179b3a5668320eab59a07e4de7b747546d.tar.gz
* gc.c (rb_gc_unprotect_logging): throw rb_memerror when it cannot
allocate memory. This is pointed out by Facebook's Infer. * gc.c (gc_prof_setup_new_record): ditto. * regparse.c (parse_regexp): ditto. * util.c (MALLOC): use xmalloc and xfree like above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index 92885754a4..0f1bbc7305 100644
--- a/gc.c
+++ b/gc.c
@@ -5962,6 +5962,7 @@ rb_gc_unprotect_logging(void *objptr, const char *filename, int line)
}
else {
ptr = (char *)malloc(strlen(buff) + 1);
+ if (!ptr) rb_memerror();
strcpy(ptr, buff);
}
st_insert(rgengc_unprotect_logging_table, (st_data_t)ptr, cnt);
@@ -8523,8 +8524,11 @@ gc_prof_setup_new_record(rb_objspace_t *objspace, int reason)
objspace->profile.records = malloc(sizeof(gc_profile_record) * objspace->profile.size);
}
if (index >= objspace->profile.size) {
+ void *ptr;
objspace->profile.size += 1000;
- objspace->profile.records = realloc(objspace->profile.records, sizeof(gc_profile_record) * objspace->profile.size);
+ ptr = realloc(objspace->profile.records, sizeof(gc_profile_record) * objspace->profile.size);
+ if (!ptr) rb_memerror();
+ objspace->profile.records = ptr;
}
if (!objspace->profile.records) {
rb_bug("gc_profile malloc or realloc miss");