[tor-commits] [tor/master] Handle tor_munmap_file(NULL) consistently

nickm at torproject.org nickm at torproject.org
Mon Mar 31 16:06:16 UTC 2014


commit 7cdb50e86604c33cfbf5e94ab56629f0bf92b804
Author: Nick Mathewson <nickm at torproject.org>
Date:   Mon Mar 31 11:35:39 2014 -0400

    Handle tor_munmap_file(NULL) consistently
---
 src/common/compat.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/common/compat.c b/src/common/compat.c
index ead96ca..135f2c9 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -354,7 +354,9 @@ tor_mmap_file(const char *filename)
 int
 tor_munmap_file(tor_mmap_t *handle)
 {
-  tor_assert(handle != NULL);
+  if (handle == NULL)
+    return 0;
+
   if (handle->data) {
     /* This is an ugly cast, but without it, "data" in struct tor_mmap_t would
        have to be redefined as non-const. */
@@ -394,8 +396,9 @@ int
 tor_munmap_file(tor_mmap_t *handle)
 {
   char *d = NULL;
+  if (handle == NULL)
+    return 0;
 
-  tor_assert(handle != NULL);
   d = (char*)handle->data;
   tor_free(d);
   memwipe(handle, 0, sizeof(tor_mmap_t));





More information about the tor-commits mailing list