diff src/ov-class.cc @ 12620:6f3f18957851 stable

ov-class.cc: Fix segfault when assigning class to struct object (bug #33014) * ov-class.cc (std::string octave_class:get_current_method_class (void)): Check if the current object is hierarchical and the current function is defined before attemptting to find the dispatch class.
author David Bateman <dbateman@free.fr>
date Mon, 18 Apr 2011 17:40:03 -0700
parents 7a5aacf65f81
children 969ed305dde5
line wrap: on
line diff
--- a/src/ov-class.cc	Mon Apr 18 17:29:17 2011 -0700
+++ b/src/ov-class.cc	Mon Apr 18 17:40:03 2011 -0700
@@ -121,12 +121,15 @@
 {
   std::string retval = class_name ();
 
-  octave_function *fcn = octave_call_stack::current ();
+  if (nparents () > 0)
+    {
+      octave_function *fcn = octave_call_stack::current ();
 
-  // Here we are just looking to see if FCN is a method or constructor
-  // for any class, not specifically this one.
-  if (fcn->is_class_method () || fcn->is_class_constructor ())
-    retval = fcn->dispatch_class ();
+      // Here we are just looking to see if FCN is a method or constructor
+      // for any class, not specifically this one.
+      if (fcn && (fcn->is_class_method () || fcn->is_class_constructor ()))
+        retval = fcn->dispatch_class ();
+    }
 
   return retval;
 }