]> granicus.if.org Git - php/commitdiff
Don't report mmap failure if it is expected
authorDavid Carlier <devnexen@gmail.com>
Tue, 21 Aug 2018 22:51:54 +0000 (23:51 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 22 Aug 2018 09:19:52 +0000 (11:19 +0200)
When using mmap with MAP_FIXED_NOREPLACE or MAP_FIXED|MAP_EXCL
an mmap failure is not an error condition, so do not print an
error message in this case.

Zend/zend_alloc.c

index 8eec54c6f703fcb37328462e91f669328c10b3a8..d81616a87a4b20bfc76d8d2ae0745556c9ddf10d 100644 (file)
@@ -432,7 +432,7 @@ static void *zend_mm_mmap_fixed(void *addr, size_t size)
        void *ptr = mmap(addr, size, PROT_READ | PROT_WRITE, flags /*| MAP_POPULATE | MAP_HUGETLB*/, -1, 0);
 
        if (ptr == MAP_FAILED) {
-#if ZEND_MM_ERROR
+#if ZEND_MM_ERROR && !defined(MAP_FIXED_NOREPLACE) && !defined(MAP_EXCL)
                fprintf(stderr, "\nmmap() failed: [%d] %s\n", errno, strerror(errno));
 #endif
                return NULL;