Skip to content

Commit

Permalink
somehow the gadget cache got dropped during the refactoring, add it back
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Kyle committed Feb 16, 2024
1 parent 5959ac9 commit dcc7838
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions angrop/gadget_finder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def get_duplicates(self):

def find_gadgets(self, processes=4, show_progress=True):
gadgets = []
self._cache = defaultdict(set)
self._cache = {}

initargs = (self.gadget_analyzer,)
with Pool(processes=processes, initializer=_set_global_gadget_analyzer, initargs=initargs) as pool:
Expand All @@ -137,7 +137,7 @@ def find_gadgets(self, processes=4, show_progress=True):

def find_gadgets_single_threaded(self, show_progress=True):
gadgets = []
self._cache = defaultdict(set)
self._cache = {}

assert self.gadget_analyzer is not None

Expand Down Expand Up @@ -186,8 +186,13 @@ def _addresses_to_check_with_caching(self, show_progress=True):
continue
if self._is_simple_gadget(a, bl):
h = self.block_hash(bl)
self._cache[h].add(a)

if h not in self._cache:
self._cache[h] = {a}
else:
# we only return the first unique gadget
# so skip duplicates
self._cache[h].add(a)
continue
yield a

def block_hash(self, block):# pylint:disable=no-self-use
Expand Down

0 comments on commit dcc7838

Please sign in to comment.