Mercurial > octave
changeset 31654:33ce26ffc42b stable
Stop potential invalid memory access in Array.dim3() (bug #63466)
* Array.h (dim3): Check whether ndims() >= 3 before accessing third element of
m_dimensions.
* Array.h: Correct Doxygen example text for creating new Array object.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 08 Dec 2022 17:56:31 -0800 |
parents | 24bd675bceab |
children | edd01ca92952 963672a9ae7b |
files | liboctave/array/Array.h |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/array/Array.h Wed Dec 07 14:26:00 2022 +0100 +++ b/liboctave/array/Array.h Thu Dec 08 17:56:31 2022 -0800 @@ -54,7 +54,7 @@ //! //! @code{.cc} //! // 3 D Array with 10 rows, 20 columns, and 5 pages, filled with 7.0 -//! Array<double> A Array<double (dim_vector (10, 20, 5), 7.0); +//! Array<double> A (dim_vector (10, 20, 5), 7.0); //! //! // set value for row 0, column 10, and page 3 //! A(0, 10, 3) = 2.5; @@ -477,7 +477,7 @@ //! Get the third dimension of the array (number of pages) //@{ OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type dim3 (void) const - { return m_dimensions(2); } + { return m_dimensions.ndims () >= 3 ? m_dimensions(2) : 1; } OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type pages (void) const { return dim3 (); } //@}