Mercurial > octave
changeset 31189:820d2c802247 stable
fortran_vec: Fix instances of method chaining that may cause dangling pointer.
* libinterp/corefcn/quandcc.cc (Fquadcc): Replace method chaining with a
separate line for NDArray object to avoid going out of scope.
* libinterp/corefcn/__ilu__.cc (F__iluc__): Obtain RowVector and ColumnVector
objects in separate line to remain in scope.
* libinterp/corefcn/__ichol__.cc (F__icholt__): Obtain RowVector object in
separate line to remain in scope.
For more details: https://octave.discourse.group/t/3132
author | Maged Rifaat <magedrifaat@gmail.com> |
---|---|
date | Mon, 15 Aug 2022 00:22:55 +0200 |
parents | 84df79fb637d |
children | 9a0e3f0b3823 bb9d776eafac |
files | libinterp/corefcn/__ichol__.cc libinterp/corefcn/__ilu__.cc libinterp/corefcn/quadcc.cc |
diffstat | 3 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/__ichol__.cc Fri Aug 12 15:56:50 2022 +0200 +++ b/libinterp/corefcn/__ichol__.cc Mon Aug 15 00:22:55 2022 +0200 @@ -435,9 +435,10 @@ { SparseMatrix L; SparseMatrix sm_l = Ftril (args(0))(0).sparse_matrix_value (); + RowVector sm_col_norms = xcolnorms (sm_l, 1); ichol_t <SparseMatrix, double, ichol_mult_real, ichol_checkpivot_real> - (sm_l, L, xcolnorms (sm_l, 1).fortran_vec (), droptol, michol); + (sm_l, L, sm_col_norms.fortran_vec (), droptol, michol); return ovl (L); }
--- a/libinterp/corefcn/__ilu__.cc Fri Aug 12 15:56:50 2022 +0200 +++ b/libinterp/corefcn/__ilu__.cc Mon Aug 15 00:22:55 2022 +0200 @@ -483,9 +483,11 @@ SparseMatrix sm_l = Ftril (ovl (sm, -1))(0).sparse_matrix_value (); SparseMatrix U, L; + RowVector sm_col_norms = xcolnorms (sm); + ColumnVector sm_row_norms = xrownorms (sm); ilu_crout <SparseMatrix, double> (sm_l, sm_u, L, U, - xcolnorms (sm).fortran_vec (), - xrownorms (sm).fortran_vec (), + sm_col_norms.fortran_vec (), + sm_row_norms.fortran_vec (), droptol, milu); SparseMatrix speye (DiagMatrix (L.cols (), L.cols (), 1.0));
--- a/libinterp/corefcn/quadcc.cc Fri Aug 12 15:56:50 2022 +0200 +++ b/libinterp/corefcn/quadcc.cc Mon Aug 15 00:22:55 2022 +0200 @@ -1668,7 +1668,8 @@ else { // Intervals around singularities. - sing = args(4).array_value ().fortran_vec (); + NDArray arr = args(4).array_value (); + sing = arr.fortran_vec (); iivals[0] = a; std::copy_n (sing, nivals-1, iivals+1); iivals[nivals] = b;