Mercurial > hg > octave-jordi
changeset 17896:f05f571ff1fa
Fix null pointer access in octave_fcn_binder::maybe_binder
* libinterp/octave-value/ov-fcn-handle.cc(maybe_binder): Avoid possible null
pointer access.
author | PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> |
---|---|
date | Sun, 10 Nov 2013 12:26:14 +0530 |
parents | ed2ef5d96929 |
children | 185038fe7a16 |
files | libinterp/octave-value/ov-fcn-handle.cc |
diffstat | 1 files changed, 12 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-fcn-handle.cc +++ b/libinterp/octave-value/ov-fcn-handle.cc @@ -1884,12 +1884,19 @@ octave_user_function *usr_fcn = f.user_function_value (false); tree_parameter_list *param_list = usr_fcn ? usr_fcn->parameter_list () : 0; - // Verify that the body is a single expression (always true in theory). + tree_statement_list *cmd_list = NULL; + tree_expression *body_expr = NULL; - tree_statement_list *cmd_list = usr_fcn ? usr_fcn->body () : 0; - tree_expression *body_expr = (cmd_list->length () == 1 - ? cmd_list->front ()->expression () : 0); - + if (usr_fcn) + { + cmd_list = usr_fcn->body (); + if (cmd_list) + { + // Verify that body is a single expression (always true in theory). + body_expr = (cmd_list->length () == 1 + ? cmd_list->front ()->expression () : 0); + } + } if (body_expr && body_expr->is_index_expression () && ! (param_list && param_list->takes_varargs ()))