]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
runtime: Correct test of mmap return value.
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 1 Nov 2011 04:55:15 +0000 (04:55 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 1 Nov 2011 04:55:15 +0000 (04:55 +0000)
From-SVN: r180731

libgo/runtime/mem.c

index 4267c55fb47c3fa27b597ac4655d54a03195cf77..4e1103e130a548e7f8dba651cec813b772dfd0e5 100644 (file)
@@ -85,6 +85,7 @@ void*
 runtime_SysReserve(void *v, uintptr n)
 {
        int fd = -1;
+       void *p;
 
        // On 64-bit, people with ulimit -v set complain if we reserve too
        // much address space.  Instead, assume that the reservation is okay
@@ -103,7 +104,11 @@ runtime_SysReserve(void *v, uintptr n)
        fd = dev_zero;
 #endif
 
-       return runtime_mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, fd, 0);
+       p = runtime_mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, fd, 0);
+       if((uintptr)p < 4096 || -(uintptr)p < 4096) {
+               return nil;
+       }
+       return p;
 }
 
 void