From bug-octave-request at bevo dot che dot wisc dot edu Tue Nov 18 22:52:48 1997 Subject: saving undefined variables in functions From: "John W. Eaton" To: Maximilian Pitschi Cc: bug-octave at bevo dot che dot wisc dot edu Date: Tue, 18 Nov 1997 22:46:28 -0600 On 18-Nov-1997, Maximilian Pitschi wrote: | Bug report for Octave 2.0.9 configured for hppa1.1-hp-hpux10.20 | | Trying to (implicitly or explicitly) save variables with the save | command that are not defined causes octave to dump the core. | | Repeat-By: | --------- | | f and g are functions, the second arguments a2 of which are optional | arguments. | | f.m: | | function f(a1, a2) | save('vars.mat', 'a1', 'a2'); | | g.m: | | function g(a1, a2) | save('vars.mat'); | | Now, calling f with two arguments is o.k., whereas calling f with | one argument terminates octave: | | /opt/pubdom/bin/octave | Octave, version 2.0.9 (hppa1.1-hp-hpux10.20). | Copyright (C) 1996, 1997 John W. Eaton. | This is free software with ABSOLUTELY NO WARRANTY. | For details, type `warranty'. | | octave:1> f(1,2) | octave:2> f(1) | error: illegal instruction -- stopping myself... | attempting to save variables to `octave-core'... | | In the above situtation the problem --- saving an undefined | variable --- is more or less obvious. Unfortunately, function g, | which is supposed to save all defined variables, behaves | the same way. Please try the following patch. Thanks, jwe Tue Nov 18 04:27:55 1997 John W. Eaton * load-save.cc (do_save): Avoid dereferencing NULL pointers. *** /home/jwe/src/octave-releases/octave-2.0.9/src/load-save.cc Mon May 19 19:55:53 1997 --- load-save.cc Tue Nov 18 22:42:05 1997 *************** *** 2238,2243 **** --- 2238,2247 ---- string help = sr->help (); int global = sr->is_linked_to_global (); tree_fvc *tmp = sr->def (); + + if (! tmp) + return; + octave_value tc = tmp->eval (0); if (tc.is_undefined ())