Merge pull request #407 from crytic/dev-improve-unini-state

Improve uninitialized-state: remove FPs due to storage variables
pull/409/head
Feist Josselin 5 years ago committed by GitHub
commit e7608a1a44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      slither/detectors/variables/uninitialized_state_variables.py

@ -11,6 +11,7 @@
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import InternalCall, LibraryCall from slither.slithir.operations import InternalCall, LibraryCall
from slither.slithir.variables import ReferenceVariable
class UninitializedStateVarsDetection(AbstractDetector): class UninitializedStateVarsDetection(AbstractDetector):
@ -56,7 +57,12 @@ Initialize all the variables. If a variable is meant to be initialized to zero,
if ir.function: if ir.function:
for param in ir.function.parameters: for param in ir.function.parameters:
if param.location == 'storage': if param.location == 'storage':
ret.append(ir.arguments[idx]) # If its a storage variable, add either the variable
# Or the variable it points to if its a reference
if isinstance(ir.arguments[idx], ReferenceVariable):
ret.append(ir.arguments[idx].points_to_origin)
else:
ret.append(ir.arguments[idx])
idx = idx + 1 idx = idx + 1
return ret return ret

Loading…
Cancel
Save