提交 81805e05 编写于 作者: J Jesse Jones 提交者: Brian Anderson

Check for oom in a few more places

上级 0402360a
......@@ -87,6 +87,10 @@ memory_region::realloc(void *mem, size_t orig_size) {
size_t size = orig_size + HEADER_SIZE;
alloc_header *newMem = (alloc_header *)::realloc(alloc, size);
if (newMem == NULL) {
fprintf(stderr, "memory_region::realloc> Out of memory allocating %ld bytes", size);
abort();
}
# if RUSTRT_TRACK_ALLOCATIONS >= 1
assert(newMem->magic == MAGIC);
......@@ -118,6 +122,10 @@ memory_region::malloc(size_t size, const char *tag, bool zero) {
size_t old_size = size;
size += HEADER_SIZE;
alloc_header *mem = (alloc_header *)::malloc(size);
if (mem == NULL) {
fprintf(stderr, "memory_region::malloc> Out of memory allocating %ld bytes", size);
abort();
}
# if RUSTRT_TRACK_ALLOCATIONS >= 1
mem->magic = MAGIC;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册