Mercurial > octave
changeset 20758:f819397c0bc1 stable
Stop segfault when find() called with 6 outputs (bug #42424).
* find.cc (find_nonzero_elem_idx): Restrict nargout to std::min (nargout, 5).
Remove default label in case statement which is no longer reachable.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 25 Nov 2015 13:31:40 -0800 |
parents | a0655d18c9cc |
children | fe5728e62848 |
files | libinterp/corefcn/find.cc |
diffstat | 1 files changed, 2 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/find.cc Tue Nov 24 19:58:10 2015 -0800 +++ b/libinterp/corefcn/find.cc Wed Nov 25 13:31:40 2015 -0800 @@ -87,6 +87,7 @@ find_nonzero_elem_idx (const Sparse<T>& v, int nargout, octave_idx_type n_to_find, int direction) { + nargout = std::min (nargout, 5); octave_value_list retval ((nargout == 0 ? 1 : nargout), Matrix ()); octave_idx_type nr = v.rows (); @@ -217,11 +218,6 @@ case 2: retval(1) = j_idx; retval(0) = i_idx; - break; - - default: - panic_impossible (); - break; } return retval; @@ -232,6 +228,7 @@ octave_idx_type n_to_find, int direction) { // There are far fewer special cases to handle for a PermMatrix. + nargout = std::min (nargout, 5); octave_value_list retval ((nargout == 0 ? 1 : nargout), Matrix ()); octave_idx_type nr = v.rows (); @@ -315,11 +312,6 @@ case 2: retval(1) = j_idx; retval(0) = i_idx; - break; - - default: - panic_impossible (); - break; } return retval;