From: Zachary T Welch <[email protected]>

If mmap fails, be sure to close the maps file before returning an error.

Signed-off-by: Zachary T Welch <[email protected]>
Signed-off-by: Ken Werner <[email protected]>
---
 src/os-linux.h |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/os-linux.h b/src/os-linux.h
index af301ce..4e225dc 100644
--- a/src/os-linux.h
+++ b/src/os-linux.h
@@ -80,7 +80,11 @@ maps_init (struct map_iterator *mi, pid_t pid)
       cp = mmap (0, mi->buf_size, PROT_READ | PROT_WRITE,
                 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
       if (cp == MAP_FAILED)
-       return -1;
+       {
+         close(mi->fd);
+         mi->fd = -1;
+         return -1;
+       }
       else
        {
          mi->offset = 0;
-- 
1.7.4.1


_______________________________________________
Libunwind-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/libunwind-devel

Reply via email to