summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2014-03-30 12:53:48 +0400
committerIvan Maidanski <ivmai@mail.ru>2014-05-03 00:33:17 +0400
commitfc12c339246d10dd42a8e8650223e38aadf2c988 (patch)
treecccb3499b339604573a85e951b5e2a07bddee3c6
parent62bfeb0d34a13ee1bea27a5836ec87e703ab5f3d (diff)
downloadbdwgc-fc12c339246d10dd42a8e8650223e38aadf2c988.tar.gz
Fix out-of-memory case in new_back_edges, push_in_progress (backgraph)
* backgraph.c (new_back_edges): Abort if not enough memory. * backgraph.c (push_in_progress): Prevent null pointer dereference in BCOPY() if allocation failed (due to not enough memory).
-rw-r--r--backgraph.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/backgraph.c b/backgraph.c
index 5cc85b4a..4b087e43 100644
--- a/backgraph.c
+++ b/backgraph.c
@@ -89,6 +89,8 @@ static back_edges * new_back_edges(void)
back_edge_space = (back_edges *)GET_MEM(
ROUNDUP_PAGESIZE_IF_MMAP(MAX_BACK_EDGE_STRUCTS
* sizeof(back_edges)));
+ if (NULL == back_edge_space)
+ ABORT("Insufficient memory for back edges");
GC_add_to_our_memory((ptr_t)back_edge_space,
MAX_BACK_EDGE_STRUCTS*sizeof(back_edges));
}
@@ -141,8 +143,9 @@ static void push_in_progress(ptr_t p)
GET_MEM(in_progress_size * sizeof(ptr_t));
GC_add_to_our_memory((ptr_t)new_in_progress_space,
in_progress_size * sizeof(ptr_t));
- BCOPY(in_progress_space, new_in_progress_space,
- n_in_progress * sizeof(ptr_t));
+ if (new_in_progress_space != NULL)
+ BCOPY(in_progress_space, new_in_progress_space,
+ n_in_progress * sizeof(ptr_t));
in_progress_space = new_in_progress_space;
/* FIXME: This just drops the old space. */
}