changeset 12563:681bb733f4f4

MatrixType:: plug memory leak (bug #32804).
author Jordi Gutiérrez Hermoso <jordigh@gmail.com>
date Fri, 01 Apr 2011 03:09:35 -0600
parents c686d2be0102
children 61cd086e9aeb
files liboctave/ChangeLog liboctave/MatrixType.cc
diffstat 2 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Thu Mar 31 21:16:44 2011 -0700
+++ b/liboctave/ChangeLog	Fri Apr 01 03:09:35 2011 -0600
@@ -1,3 +1,8 @@
+2011-04-01  Jordi GutiƩrrez Hermoso  <jordigh@gmail.com>
+
+	* MatrixType (MatrixType::operator =): Plug memory leak due to
+	improper handling of perm array (bug #32804).
+
 2011-03-29  Rik  <octave@nomad.inbox5.com>
 
 	* Array.cc (diag): Treat empty vector (1x0 or 0x1) as valid input.
--- a/liboctave/MatrixType.cc	Thu Mar 31 21:16:44 2011 -0700
+++ b/liboctave/MatrixType.cc	Fri Apr 01 03:09:35 2011 -0600
@@ -921,14 +921,20 @@
       lower_band = a.lower_band;
       dense = a.dense;
       full = a.full;
-      nperm = a.nperm;
 
-      if (nperm != 0)
+      if (a.nperm != 0)
         {
-          perm = new octave_idx_type [nperm];
-          for (octave_idx_type i = 0; i < nperm; i++)
+          if (nperm)
+            {
+              delete[] perm;
+            }
+
+          perm = new octave_idx_type [a.nperm];
+          for (octave_idx_type i = 0; i < a.nperm; i++)
             perm[i] = a.perm[i];
         }
+
+      nperm = a.nperm;
     }
 
   return *this;