test/crit-recode: fix file handle leak in image read

Use 'with' statement instead of open().read() to ensure the
file handle is properly closed.

Assisted-by: Claude Code (claude-opus-4-6)
Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
Adrian Reber 2026-07-06 13:29:27 +00:00 committed by Radostin Stoyanov
parent 4a50cc1744
commit c40d1b8b10

View file

@ -61,7 +61,8 @@ for imgf in find.stdout.readlines():
if imgf_b.startswith(b'rule-'):
continue
o_img = open(imgf.decode(), "rb").read()
with open(imgf.decode(), "rb") as fh:
o_img = fh.read()
if not recode_and_check(imgf, o_img, False):
test_pass = False
if not recode_and_check(imgf, o_img, True):