# HG changeset patch # User Rik # Date 1506112588 25200 # Node ID 88a593fa1388fd5cc05ad313552350925fc3330a # Parent 2a9eec536cfd515889b9067128bec8b2a396d84d Stop out-of-bounds memory access during convolution (bug #52067). * oct-convn.cc (convolve): Check size of return matrix and short-circuit return from function if it is empty (as can happen when shape == "valid"). diff -r 2a9eec536cfd -r 88a593fa1388 liboctave/numeric/oct-convn.cc --- a/liboctave/numeric/oct-convn.cc Fri Sep 22 12:46:53 2017 -0700 +++ b/liboctave/numeric/oct-convn.cc Fri Sep 22 13:36:28 2017 -0700 @@ -152,6 +152,11 @@ MArray c (cdims, T ()); + // "valid" shape can sometimes result in empty matrices which must avoid + // calling Fortran code which does not expect this (bug #52067) + if (c.isempty ()) + return c; + convolve_nd (a.fortran_vec (), adims, adims.cumulative (), b.fortran_vec (), bdims, bdims.cumulative (), c.fortran_vec (), cdims.cumulative (),