From bdf0fb323e29699b3102db6a9c8548ce85cd78a3 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sat, 30 Mar 2024 17:41:44 -0700 Subject: [PATCH] early bailout conditions caught by type check --- mem_edit/linux.py | 2 ++ mem_edit/windows.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mem_edit/linux.py b/mem_edit/linux.py index 80d6e0c..c5b1950 100644 --- a/mem_edit/linux.py +++ b/mem_edit/linux.py @@ -61,6 +61,8 @@ class Process(AbstractProcess): self.pid = process_id def close(self) -> None: + if self.pid is None: + return os.kill(self.pid, signal.SIGSTOP) os.waitpid(self.pid, 0) ptrace(ptrace_commands['PTRACE_DETACH'], self.pid, 0, 0) diff --git a/mem_edit/windows.py b/mem_edit/windows.py index dc03521..49f92eb 100644 --- a/mem_edit/windows.py +++ b/mem_edit/windows.py @@ -233,6 +233,8 @@ class Process(AbstractProcess): logger.debug(f'Checking name for pid {pid}') with Process.open_process(pid) as process: path = process.get_path() + if path is None: + continue name = os.path.basename(path) logger.debug(f'Name was "{name}"')