mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[poincare] Fix leak in multiplication::distributeOnOperandAtIndex
Change-Id: Iba88f1c80a68b5b5c34d8448717e9b492f94c451
This commit is contained in:
@@ -437,11 +437,12 @@ Expression * Multiplication::distributeOnOperandAtIndex(int i, Context & context
|
||||
// This function turns a*(b+c) into a*b + a*c
|
||||
// We avoid deleting and creating a new addition
|
||||
Addition * a = static_cast<Addition *>(editableOperand(i));
|
||||
removeOperand(a, false);
|
||||
for (int j = 0; j < a->numberOfOperands(); j++) {
|
||||
Multiplication * m = static_cast<Multiplication *>(clone());
|
||||
Expression * termJ = a->editableOperand(j);
|
||||
replaceOperand(operand(i), termJ->clone(), false);
|
||||
Expression * m = clone();
|
||||
a->replaceOperand(termJ, m, true);
|
||||
a->replaceOperand(termJ, m, false);
|
||||
m->addOperand(termJ);
|
||||
m->shallowReduce(context, angleUnit); // pi^(-1)*(pi + x) -> pi^(-1)*pi + pi^(-1)*x -> 1 + pi^(-1)*x
|
||||
}
|
||||
replaceWith(a, true);
|
||||
|
||||
Reference in New Issue
Block a user