Skip to content

Commit

Permalink
engine: Handle a case when function has no range associated.
Browse files Browse the repository at this point in the history
E.g. when it was mis-detected as being a function in first place (when
accepting a symbol list files, all symbols in executable area are treated
as a function, but it still may be a constant data).
  • Loading branch information
pfalcon committed Jul 26, 2015
1 parent b8f38cd commit 74323e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ def add_insn(self, addr, sz):
def get_end(self):
if self.end is not None:
return self.end
return self.ranges.bounds()[1]
bounds = self.ranges.bounds()
if bounds:
return bounds[1]

def get_end_method(self):
if self.end is not None:
Expand Down Expand Up @@ -558,7 +560,8 @@ def finish_func(f):
if f:
log.info("Function %s (0x%x) ranges: %s" % (ADDRESS_SPACE.get_label(f.start), f.start, f.ranges.str(hex)))
end = f.get_end()
ADDRESS_SPACE.set_func_end(f, end)
if end is not None:
ADDRESS_SPACE.set_func_end(f, end)

def analyze(callback=lambda cnt:None):
cnt = 0
Expand Down
3 changes: 2 additions & 1 deletion rangeset.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def add(self, r):
self.r.append(r)

def bounds(self):
return (self.r[0][0], self.r[-1][1])
if self.r:
return (self.r[0][0], self.r[-1][1])

def __str__(self):
return str(self.r)
Expand Down

0 comments on commit 74323e9

Please sign in to comment.