changeset 8028:f0fbf47c914c

avoid null pointer call in Array<T>::hermitian
author Jaroslav Hajek <highegg@gmail.com>
date Sat, 09 Aug 2008 23:33:03 +0200
parents fd13f9f7dbac
children 090001c04619
files liboctave/Array.cc liboctave/ChangeLog
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/Array.cc	Mon Aug 11 10:59:30 2008 +0200
+++ b/liboctave/Array.cc	Sat Aug 09 23:33:03 2008 +0200
@@ -1262,11 +1262,21 @@
 }
 
 template <class T>
+static T
+no_op_fcn (const T& x)
+{
+  return x;
+}
+
+template <class T>
 Array<T>
 Array<T>::hermitian (T (*fcn) (const T&)) const
 {
   assert (ndims () == 2);
 
+  if (! fcn)
+    fcn = no_op_fcn<T>;
+
   octave_idx_type nr = dim1 ();
   octave_idx_type nc = dim2 ();
 
--- a/liboctave/ChangeLog	Mon Aug 11 10:59:30 2008 +0200
+++ b/liboctave/ChangeLog	Sat Aug 09 23:33:03 2008 +0200
@@ -1,3 +1,8 @@
+2008-08-11  Jaroslav Hajek <highegg@gmail.com>
+
+	* Array.cc (no_op_fcn): New static function.
+	(Array<T>::hermitian): If fcn is null, set to no_op_fcn.
+
 2008-08-07  John W. Eaton  <jwe@octave.org>
 
 	* sprse-base-chol.h, oct-sparse.h: Don't include config.h.