Fix wrong return value check of mmap function
authorTristan Bauer <67098820+trisbauer@users.noreply.github.com>
Thu, 18 Jun 2020 09:45:24 +0000 (11:45 +0200)
committerPauli <paul.dale@oracle.com>
Tue, 23 Jun 2020 00:08:28 +0000 (10:08 +1000)
The mmap function never returns NULL. If an error occurs, the function returns MAP_FAILED.

CLA: trivial

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12187)

crypto/mem_sec.c

index e28a43e2954656661df2084e2018890ea1425be3..ddc0a370e6232015729a0965d85a2380d1008370 100644 (file)
@@ -514,7 +514,7 @@ static void sh_done(void)
     OPENSSL_free(sh.freelist);
     OPENSSL_free(sh.bittable);
     OPENSSL_free(sh.bitmalloc);
-    if (sh.map_result != NULL && sh.map_size)
+    if (sh.map_result != MAP_FAILED && sh.map_size)
         munmap(sh.map_result, sh.map_size);
     memset(&sh, 0, sizeof(sh));
 }