# HG changeset patch # User Markus Mützel # Date 1649440541 -7200 # Node ID 84fa12727b435a1f58ed6b1aa8859b4e1bbc4814 # Parent 1325f0c66460d12888da37019dea3f2338a09f61 Avoid out-of-bounds indexing when checking for broadcastable inplace operators (bug #38466). * liboctave/numeric/bsxfun.h (is_valid_inplace_bsxfun): Check if non-singleton dimensions of the right hand side operator are broadcastable. Trailing dimensions are always treated as singleton. diff -r 1325f0c66460 -r 84fa12727b43 liboctave/numeric/bsxfun.h --- a/liboctave/numeric/bsxfun.h Fri Apr 08 13:48:13 2022 -0400 +++ b/liboctave/numeric/bsxfun.h Fri Apr 08 19:55:41 2022 +0200 @@ -68,13 +68,13 @@ if (r_nd < x_nd) return false; - for (int i = 0; i < r_nd; i++) + for (int i = 0; i < x_nd; i++) { octave_idx_type rk = rdv(i); octave_idx_type xk = xdv(i); // Only two valid conditions to check; can't stretch rk - if (! ((rk == xk) || (rk != 1 && xk == 1))) + if ((rk != xk) && xk != 1) return false; }