Commit 72f451ee authored by Declan Snyder's avatar Declan Snyder Committed by Anas Nashif
Browse files

scripts: kconfiglib: Fix file leaks

Fixing a couple cases of a programming error where a file is not closed
in case of an exception, which was causing resource leak warnings in
some cases when encountering a kconfig error.

Signed-off-by: default avatarDeclan Snyder <declan.snyder@nxp.com>
parent efdd8580
Loading
Loading
Loading
Loading
+3 −1
Changes for scripts/kconfig/kconfiglib.py: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1087,7 +1087,7 @@ class Kconfig(object):
            self.top_node.next = None
        except UnicodeDecodeError as e:
            _decoding_error(e, self.filename)

        finally:
            # Close the top-level Kconfig file. __self__ fetches the 'file' object
            # for the method.
            self._readline.__self__.close()
@@ -2998,7 +2998,9 @@ class Kconfig(object):

                for filename in filenames:
                    self._enter_file(filename)
                    try:
                        prev = self._parse_block(None, parent, prev)
                    finally:
                        self._leave_file()

            elif t0 is end_token: