Check for oom in a few more places
This commit is contained in:
parent
0402360abb
commit
81805e0568
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user