From a00bbd87654960f5e39c213a4e0a484472bb8bd3 Mon Sep 17 00:00:00 2001 From: Ajax Date: Thu, 3 Aug 2017 17:35:24 +0200 Subject: 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__ --- miasm2/expression/expression.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'miasm2/expression/expression.py') 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): -- cgit 1.4.1