]> granicus.if.org Git - gc/commitdiff
Fix GC_unix_mmap_get_mem for open of /dev/zero failure
authorIvan Maidanski <ivmai@mail.ru>
Fri, 19 Oct 2012 05:10:07 +0000 (09:10 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 19 Oct 2012 13:27:09 +0000 (17:27 +0400)
* os_dep.c (GC_unix_mmap_get_mem): Check open("/dev/zero") (or open
of similar file on Symbian) result and abort (with the appropriate
message) on failure (only if USE_MMAP_ANON is undefined).

os_dep.c

index 2524c8644d959abf99d96784394dbfcbbaef2a6a..eb6b846ce3ce32ff90ba2ec0e9eb8865379506b2 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -2091,6 +2091,9 @@ STATIC ptr_t GC_unix_mmap_get_mem(word bytes)
 #       else
           zero_fd = open("/dev/zero", O_RDONLY);
 #       endif
+          if (zero_fd == -1)
+            ABORT("Could not open /dev/zero");
+
           fcntl(zero_fd, F_SETFD, FD_CLOEXEC);
           initialized = TRUE;
       }