Skip to content

Commit

Permalink
repl: Improve error-handling during Java feature detection
Browse files Browse the repository at this point in the history
- Avoid crashing if either create_script() or load() fails.
- Always unload the script afterwards.
  • Loading branch information
oleavr committed May 3, 2023
1 parent 1d64201 commit 9b65341
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions frida_tools/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,14 +619,18 @@ def _set_autoperform(self, state: bool) -> None:

def _is_java_available(self) -> bool:
assert self._session is not None
script = self._session.create_script(
name="java_check", source="rpc.exports.javaAvailable = () => Java.available;", runtime=self._runtime
)
script.load()
script = None
try:
script = self._session.create_script(
name="java_check", source="rpc.exports.javaAvailable = () => Java.available;", runtime=self._runtime
)
script.load()
return script.exports_sync.java_available()
except:
return False
finally:
if script is not None:
script.unload()

def _refresh_prompt(self) -> None:
self._prompt_string = self._create_prompt()
Expand Down

0 comments on commit 9b65341

Please sign in to comment.