Skip to content

Commit

Permalink
Merge pull request #153 from shortdoom/fix-detector-fail-develop
Browse files Browse the repository at this point in the history
fix: object of type NoneType has no len() - PotentialArithmOverflow detector fail
  • Loading branch information
olegggatttor authored Apr 15, 2024
2 parents 1d10755 + a2862f3 commit 49a7ef6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions slitherin/detectors/potential_arith_overflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _find_vulnerable_expressions(self, fun: Function) -> list:
errors.extend(response_errors)
if has_problems:
final_results.append((node, str(irs[-1].lvalue._type), errors))
if len(irs) > 0 and isinstance(irs[-1], ops.Return) and len(fun.return_type) == 1 and str(fun.return_type[0]) in INT_TYPES: # @todo currently works only with single returns
if len(irs) > 0 and isinstance(irs[-1], ops.Return) and fun.return_type is not None and len(fun.return_type) == 1 and str(fun.return_type[0]) in INT_TYPES: # @todo currently works only with single returns
expected_bits_cut = str(fun.return_type[0]).removeprefix("uint").removeprefix("int")
expected_bits = int(256 if not expected_bits_cut else expected_bits_cut)
has_problems = False
Expand Down Expand Up @@ -115,4 +115,4 @@ def _detect(self) -> List[Output]:
for (op, op_ret_type) in op_with_ret_type:
info += ["\t\t`", str(op), f"` returns {op_ret_type}, but the type of the resulting expression is {node_final_type}.", "\n"]
res.append(self.generate_result(info))
return res
return res

0 comments on commit 49a7ef6

Please sign in to comment.