summaryrefslogtreecommitdiff
path: root/python/scriptingprovider.py
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2023-02-02 19:56:00 -0500
committerJordan Wiens <jordan@psifertex.com>2023-02-02 19:57:16 -0500
commit77e6d1fb41b829dd23c810441fc58fb7502777f1 (patch)
tree0aad96487d55637ec9446476eb66d9fbd4e11d4e /python/scriptingprovider.py
parent34f76290a2aef8a91326b3d3ef89f20e4af9e28e (diff)
Fix current_comment clobbering bv.set_comment_at
Fixes Vector35/binaryninja-api#3682
Diffstat (limited to 'python/scriptingprovider.py')
-rw-r--r--python/scriptingprovider.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py
index f18020b9..cbd5df93 100644
--- a/python/scriptingprovider.py
+++ b/python/scriptingprovider.py
@@ -657,6 +657,7 @@ class PythonScriptingInstance(ScriptingInstance):
self.locals = BlacklistedDict(
blacklisted_vars, {"__name__": "__console__", "__doc__": None, "binaryninja": sys.modules[__name__]}
)
+ self.cached_locals = {}
self.interpreter = code.InteractiveConsole(self.locals)
self.event = threading.Event()
self.daemon = True
@@ -842,6 +843,9 @@ from binaryninja import *
self.locals["current_sections"] = None
self.locals["current_comment"] = None
+ # Keep a copy of the original version of this, so we can check if it has changed
+ self.cached_locals["current_comment"] = self.locals["current_comment"]
+
ui_locals_valid = False
if binaryninja.core_ui_enabled():
try:
@@ -983,15 +987,15 @@ from binaryninja import *
return
if self.active_func is None:
- if self.active_view.get_comment_at(self.active_addr) != self.locals["current_comment"]:
+ if self.cached_locals["current_comment"] != self.locals["current_comment"]:
self.active_view.set_comment_at(self.active_addr, self.locals["current_comment"])
else:
- if self.active_view.get_comment_at(self.active_addr) != '':
+ if self.cached_locals["current_comment"] != '':
# Prefer editing active view comment if one exists
- if self.active_view.get_comment_at(self.active_addr) != self.locals["current_comment"]:
+ if self.cached_locals["current_comment"] != self.locals["current_comment"]:
self.active_view.set_comment_at(self.active_addr, self.locals["current_comment"])
else:
- if self.active_func.get_comment_at(self.active_addr) != self.locals["current_comment"]:
+ if self.cached_locals["current_comment"] != self.locals["current_comment"]:
self.active_func.set_comment_at(self.active_addr, self.locals["current_comment"])
def update_current_selection(self):