summaryrefslogtreecommitdiff
path: root/os_dep.c
diff options
context:
space:
mode:
authorivmai <ivmai>2011-03-13 14:08:16 +0100
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:56 +0200
commit667fb0512a70f7756a2c64f0e71c03e1e49a8a4c (patch)
tree67a5fa56f2df6166f717bb634e2370db9091b73f /os_dep.c
parent35260b7ff2dc15a5194758ab6f3c73fbfb40acb3 (diff)
2011-03-13 Ivan Maidanski <ivmai@mail.ru>
* dbg_mlc.c (GC_make_closure): Fix SEGV in case GC_malloc returns NULL. * dbg_mlc.c (GC_debug_register_finalizer, GC_debug_register_finalizer_no_order, GC_debug_register_finalizer_unreachable, GC_debug_register_finalizer_ignore_self): Handle out of memory case properly (similar to GC_register_finalizer_inner). * headers.c (GC_install_header): Handle the case when alloc_hdr() returns NULL. * os_dep.c (GC_get_maps_len): Defend against missing "maps" file. * pthread_support.c (GC_mark_thread): Place a dummy return statement (which uses "id" argument) before the actual use of "id" as an array index (to suppress a warning produced by some static code analysis tools). * win32_threads.c (GC_mark_thread): Ditto. * pthread_support.c (GC_thr_init): Abort (with the appropriate message) if out of memory.
Diffstat (limited to 'os_dep.c')
-rw-r--r--os_dep.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/os_dep.c b/os_dep.c
index 768ab45..0b9813e 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -189,7 +189,9 @@ STATIC ssize_t GC_repeat_read(int fd, char *buf, size_t count)
STATIC size_t GC_get_maps_len(void)
{
int f = open("/proc/self/maps", O_RDONLY);
- size_t result = GC_get_file_len(f);
+ size_t result;
+ if (f < 0) return 0; /* treat missing file as empty */
+ result = GC_get_file_len(f);
close(f);
return result;
}
@@ -227,9 +229,9 @@ GC_INNER char * GC_get_maps(void)
/* This only matters with threads enabled, and if we use */
/* this to locate roots (not the default). */
- /* Determine the initial size of /proc/self/maps. */
- /* Note that lseek doesn't work, at least as of 2.6.15. */
# ifdef THREADS
+ /* Determine the initial size of /proc/self/maps. */
+ /* Note that lseek doesn't work, at least as of 2.6.15. */
maps_size = GC_get_maps_len();
if (0 == maps_size) return 0;
# else