aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-03-31 11:35:39 -0400
committerNick Mathewson <nickm@torproject.org>2014-03-31 11:35:39 -0400
commit7cdb50e86604c33cfbf5e94ab56629f0bf92b804 (patch)
tree2b2af45cea5cea7f2ed3085a0d5d7bdc8c0f7f36 /src/common/compat.c
parentdea81901114f2bc67cdc9d9072fbfe1b6797920e (diff)
downloadtor-7cdb50e86604c33cfbf5e94ab56629f0bf92b804.tar
tor-7cdb50e86604c33cfbf5e94ab56629f0bf92b804.tar.gz
Handle tor_munmap_file(NULL) consistently
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index ead96ca30..135f2c9af 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));