diff options
| author | Ajax <commial@gmail.com> | 2017-08-03 17:35:24 +0200 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2017-08-03 19:46:11 +0200 |
| commit | a00bbd87654960f5e39c213a4e0a484472bb8bd3 (patch) | |
| tree | e50d39a926645c855adf1f480468c6926c690625 /miasm2/expression | |
| parent | c01a309d013827a56b64359e24782e0c9bdb34ce (diff) | |
| download | miasm-a00bbd87654960f5e39c213a4e0a484472bb8bd3.tar.gz miasm-a00bbd87654960f5e39c213a4e0a484472bb8bd3.zip | |
Avoid racing ._size assignment in ExprInt
With Singleton behavior activated, ._size can be set during __new__, and reset to None during __init__. During unpickling, attributes fixes and __init__ / __new__ call order can also result in a weird behavior Actually, as _size is not modified during __new__, ExprInt behavior is now homogeneous with others Expr's __init__
Diffstat (limited to 'miasm2/expression')
| -rw-r--r-- | miasm2/expression/expression.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/miasm2/expression/expression.py b/miasm2/expression/expression.py index 435504f8..c62b3bc0 100644 --- a/miasm2/expression/expression.py +++ b/miasm2/expression/expression.py @@ -126,9 +126,12 @@ class Expr(object): raise ValueError('size is not mutable') def __init__(self): + # Common attribute + self._size = None + + # Lazy cache needs self._hash = None self._repr = None - self._size = None size = property(lambda self: self._size) @@ -390,7 +393,8 @@ class ExprInt(Expr): @arg: 'intable' number @size: int size""" super(ExprInt, self).__init__() - # Work is done in __new__ + # Work for ._arg is done in __new__ + self._size = size arg = property(lambda self: self._arg) @@ -419,7 +423,6 @@ class ExprInt(Expr): # Save parameters (__init__ is called with parameters unchanged) expr._arg = arg - expr._size = expr._arg.size return expr def __get_int(self): |