From: Nick Mathewson Date: Mon, 31 Mar 2014 15:35:39 +0000 (-0400) Subject: Handle tor_munmap_file(NULL) consistently X-Git-Tag: tor-0.2.5.4-alpha~86^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7cdb50e86604c33cfbf5e94ab56629f0bf92b804;p=thirdparty%2Ftor.git Handle tor_munmap_file(NULL) consistently --- diff --git a/src/common/compat.c b/src/common/compat.c index ead96ca30e..135f2c9af6 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));