]> arthur.barton.de Git - bup.git/commitdiff
fmincore: fix mmap leak
authorRob Browning <rlb@defaultvalue.org>
Sat, 1 Jan 2022 18:57:34 +0000 (12:57 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sat, 1 Jan 2022 20:40:22 +0000 (14:40 -0600)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/helpers.py

index 28d1c6d3595b612f17cfb14decadb0279ee4b8b9..af635ae6e8b78cdd54d37fe9ff20ac253f9f382f 100644 (file)
@@ -838,12 +838,13 @@ if _mincore:
                     # Perhaps the file was a pipe, i.e. "... | bup split ..."
                     return None
                 raise ex
-            try:
-                _mincore(m, msize, 0, result, ci * pages_per_chunk)
-            except OSError as ex:
-                if ex.errno == errno.ENOSYS:
-                    return None
-                raise
+            with m:
+                try:
+                    _mincore(m, msize, 0, result, ci * pages_per_chunk)
+                except OSError as ex:
+                    if ex.errno == errno.ENOSYS:
+                        return None
+                    raise
         return result