diff --git a/poincare/src/simplification/transform/integer_power_transform.cpp b/poincare/src/simplification/transform/integer_power_transform.cpp index 7b6d9d485..5d2210659 100644 --- a/poincare/src/simplification/transform/integer_power_transform.cpp +++ b/poincare/src/simplification/transform/integer_power_transform.cpp @@ -12,7 +12,7 @@ bool Simplification::IntegerPowerTransform(Expression * captures[]) { Power * p = static_cast(captures[0]); Integer * i1 = static_cast(captures[1]); Integer * i2 = static_cast(captures[2]); - + Expression * result = nullptr; if (i2->isNegative()) { if (i2->isEqualTo(Integer(-1))) { return false; @@ -20,12 +20,11 @@ bool Simplification::IntegerPowerTransform(Expression * captures[]) { Integer absI2 = *i2; absI2.setNegative(false); Expression * operands[2] = {new Integer(Integer::Power(*i1, absI2)), new Integer(-1)}; - Power * d = new Power(operands, false); - static_cast(p->parent())->replaceOperand(p, d, true); - return true; + result = new Power(operands, false); + } else { + result = new Integer(Integer::Power(*i1, *i2)); } - Integer * r = new Integer(Integer::Power(*i1, *i2)); - static_cast(p->parent())->replaceOperand(p, r, true); + static_cast(p->parent())->replaceOperand(p, result, true); return true; }