summaryrefslogtreecommitdiff
path: root/dyn_load.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-06-07 20:00:37 +0200
committerIvan Maidanski <ivmai@mail.ru>2012-06-07 20:56:33 +0200
commit1de90aeb38a078550f9b22a5900f959e6dcbd37b (patch)
tree52aa63e26fd3ae741bfa1a530397e1105d8cdfef /dyn_load.c
parenta237b23befdb0dd75dff2727a2a5c0d66bc96f04 (diff)
Fix GC_scratch_alloc and GC_get_maps invocations to prevent SEGV
(if out of memory) * dyn_load.c (GC_register_dynamic_libraries): If GC_scratch_alloc fails (returns null) then abort (with the appropriate message) instead of causing SEGV. * os_dep.c (GC_dirty_init): Likewise. * headers.c (GC_init_headers): Report error and exit if GC_scratch_alloc fails. * include/private/gc_priv.h (GC_scratch_alloc): Improve comment. * os_dep.c (GC_print_address_map): If GC_get_maps return null then print the appropriate message (instead of passing null to GC_err_puts thus causing SEGV).
Diffstat (limited to 'dyn_load.c')
-rw-r--r--dyn_load.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/dyn_load.c b/dyn_load.c
index a543d9e..39efc9b 100644
--- a/dyn_load.c
+++ b/dyn_load.c
@@ -760,6 +760,8 @@ GC_INNER void GC_register_dynamic_libraries(void)
/* Expansion, plus room for 0 record */
addr_map = (prmap_t *)GC_scratch_alloc(
(word)current_sz * sizeof(prmap_t));
+ if (addr_map == NULL)
+ ABORT("Insufficient memory for address map");
}
if (ioctl(fd, PIOCMAP, addr_map) < 0) {
GC_err_printf("fd = %d, errno = %d, needed_sz = %d, addr_map = %p\n",