diff --git a/src/Reducer/BinaryOpReducer.php b/src/Reducer/BinaryOpReducer.php index 8a806cb..855be5f 100644 --- a/src/Reducer/BinaryOpReducer.php +++ b/src/Reducer/BinaryOpReducer.php @@ -104,8 +104,16 @@ public function reduceMod(BinaryOp\Mod $node) { return $this->postProcess($node, $this->left($node) % $this->right($node)); } public function reduceMul(BinaryOp\Mul $node) - { return $this->postProcess($node, $this->left($node) * $this->right($node)); } + { + $left = $this->left($node); + $right = $this->right($node); + if (is_numeric($left) && is_numeric($right)) { + return $this->postProcess($node, $left * $right); + } + + return null; + } public function reduceNotEqual(BinaryOp\NotEqual $node) { return $this->postProcess($node, $this->left($node) != $this->right($node)); } diff --git a/src/Utils.php b/src/Utils.php index b421cd8..74edb7e 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -14,7 +14,7 @@ class Utils { public static function scalarToNode($value, $attrs = array()) { - if (!is_array($value)) { // Do this for arrays later + if (is_scalar($value) || $value === null) { // Do this for arrays later $attrs[AttrName::VALUE] = new ScalarValue($value); } if (is_int($value)) { @@ -44,7 +44,7 @@ public static function scalarToNode($value, $attrs = array()) $attrs[AttrName::VALUE] = new ArrayVal($valArray); return new Node\Expr\Array_($items, $attrs); } - throw new \Exception("Unknown value type"); + return null; // Skip unknown value types silently to protect against future weird types without killing deobfuscation } public static function getValueRef(Node $node)