From 02feb335c0f8b01c0ee14d493f86f7f9e49c1bf9 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Thu, 29 Jun 2023 00:34:47 +0200 Subject: Fix usage of potentially unbound variables --- extract_token_from_browser.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extract_token_from_browser.py b/extract_token_from_browser.py index b6b771b..9795605 100755 --- a/extract_token_from_browser.py +++ b/extract_token_from_browser.py @@ -115,6 +115,7 @@ else: cookies_path = default_profile_path.joinpath("Cookies") leveldb_path = default_profile_path.joinpath("Local Storage/leveldb") +con = None cookie_d_value = None cookie_ds_value = None try: @@ -126,7 +127,8 @@ except TypeError: print("Couldn't find the 'd' cookie value", file=sys.stderr) sys.exit(1) finally: - con.close() + if con: + con.close() if args.browser in ["chrome", "chrome-beta"]: bus = secretstorage.dbus_init() @@ -166,6 +168,7 @@ else: local_storage_path = default_profile_path.joinpath("webappsstore.sqlite") local_storage_query = "SELECT value FROM webappsstore2 WHERE key = 'localConfig_v2'" teams = [] +con = None local_config = None try: con = sqlite3.connect(f"file:{local_storage_path}?immutable=1", uri=True) @@ -182,7 +185,8 @@ except (OperationalError, TypeError): ) sys.exit(1) finally: - con.close() + if con: + con.close() if not local_config and leveldb_path: try: -- cgit