From: Rob Browning Date: Sat, 1 Jan 2022 18:57:34 +0000 (-0600) Subject: fmincore: fix mmap leak X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=d1c5a726387d83d526695c30b9ac7fc0498f7027;ds=sidebyside fmincore: fix mmap leak Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index 28d1c6d..af635ae 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -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