summaryrefslogtreecommitdiff
path: root/headers.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-06-07 22:00:37 +0400
committerIvan Maidanski <ivmai@mail.ru>2012-06-07 22:00:37 +0400
commit0ac7a655aba6c7e1d43ad2262e4c556879e89827 (patch)
treeaa5ddc0328c6dc51a2c60f3fbb75d69d1b757085 /headers.c
parent70d33b51b00b53fcd85c4044aa22f456dc701883 (diff)
downloadbdwgc-0ac7a655aba6c7e1d43ad2262e4c556879e89827.tar.gz
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 'headers.c')
-rw-r--r--headers.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/headers.c b/headers.c
index 71ab29f5..47cc526e 100644
--- a/headers.c
+++ b/headers.c
@@ -196,6 +196,10 @@ GC_INNER void GC_init_headers(void)
register unsigned i;
GC_all_nils = (bottom_index *)GC_scratch_alloc((word)sizeof(bottom_index));
+ if (GC_all_nils == NULL) {
+ GC_err_printf("Insufficient memory for GC_all_nils\n");
+ EXIT();
+ }
BZERO(GC_all_nils, sizeof(bottom_index));
for (i = 0; i < TOP_SZ; i++) {
GC_top_index[i] = GC_all_nils;