From 99dbd2d47b14da5fc3fd78ef16d879a0acc68fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 1 Mar 2011 09:22:23 +0000 Subject: [PATCH] yet another memory leak in CORE polynomial. --- Core/include/CGAL/CORE/poly/Poly.tcc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Core/include/CGAL/CORE/poly/Poly.tcc b/Core/include/CGAL/CORE/poly/Poly.tcc index c08c1779619..a41cf2eb858 100644 --- a/Core/include/CGAL/CORE/poly/Poly.tcc +++ b/Core/include/CGAL/CORE/poly/Poly.tcc @@ -465,6 +465,12 @@ Polynomial & Polynomial::operator-=(const Polynomial& p) { // -= // This is quadratic time multiplication! template Polynomial & Polynomial::operator*=(const Polynomial& p) { // *= + if (degree==-1) return *this; + if (p.getDegree()==-1){ + degree=-1; + delete[] coeff; + return *this; + } int d = degree + p.getDegree(); NT * c = new NT[d+1]; for (int i = 0; i<=d; i++) @@ -670,7 +676,7 @@ Polynomial Polynomial::pseudoRemainder ( contract(); // Let A = (*this). Contract A. Polynomial tmpB(B); tmpB.contract(); // local copy of B - C = *(new NT(1)); // Initialized to C=1. + C = NT(1); // Initialized to C=1. if (B.degree == -1) { std::cout << "ERROR in Polynomial::pseudoRemainder :\n" << " -- divide by zero polynomial" << std::endl;