From 00bd3b20099e921c251cb791192b03a8d24a4a2c Mon Sep 17 00:00:00 2001
From: Dirk Engling <erdgeist@erdgeist.org>
Date: Mon, 19 Apr 2021 22:36:24 +0200
Subject: unmap file if a memory allocation error occurs

---
 ot_accesslist.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ot_accesslist.c b/ot_accesslist.c
index 2e3778f..48de873 100644
--- a/ot_accesslist.c
+++ b/ot_accesslist.c
@@ -56,8 +56,9 @@ static void accesslist_readfile( void ) {
      for the maximum amount of them */
   accesslist_new->size = 0;
   info_hash = accesslist_new->list = malloc( ( maplen / 41 ) * 20 );
-  if( !accesslist_new ) {
+  if( !accesslist_new->list ) {
     fprintf( stderr, "Warning: Not enough memory to allocate %zd bytes for accesslist buffer. May succeed later.\n", ( maplen / 41 ) * 20 );
+    mmap_unmap( map, maplen);
     free(accesslist_new);
     return;
   }
-- 
cgit v1.2.3