PR 67457 points out a crash in libbacktrace when there is no memory
available.  This is because the code testing the mmap result for
failure is broken.  This patch fixes it.  Bootstrapped and ran
libbacktrace tests.  Committed to mainline.

Ian


2015-09-08  Ian Lance Taylor  <i...@google.com>

PR other/67457
* mmap.c (backtrace_alloc): Correct test for mmap failure.
Index: mmap.c
===================================================================
--- mmap.c      (revision 227528)
+++ mmap.c      (working copy)
@@ -139,7 +139,7 @@ backtrace_alloc (struct backtrace_state
       asksize = (size + pagesize - 1) & ~ (pagesize - 1);
       page = mmap (NULL, asksize, PROT_READ | PROT_WRITE,
                   MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-      if (page == NULL)
+      if (page == MAP_FAILED)
        error_callback (data, "mmap", errno);
       else
        {

Reply via email to