leastsq kills Scilab under macOS/arm64

Bug Description

Under macOS/arm64, leastsq kills Scilab when an simple error occurs in the residual function.

Steps to reproduce

// Functional behaviour obtained from integration
function YP=Model2(p,xc)
 x=1:300; df2=(exp(-x/p))/p;f2=cumsum(df2);
 YP=f2(xc)
endfunction
// Measurements
time=[10     50     70    80     100  170  200];
value= [   0.09   0.49   0.6   0.68   0.71   0.89   0.91];
// Cost function
function DV=cost(pv, xv, yv)
 DV= Model2(pv,xv)-yv;
endfunction
// Nonlinear least squares fit
p=77;
[fopt,xopt,gopt]=leastsq(list(cost,time,value),p);
pfit=xopt

under macOS/arm64 the above code crashes Scilab, but under Windows or macOS/x86_64, the exception is correctly catched:

at line     4 of function %opt    
at line   -12 of function optim   
at line    92 of function leastsq ( /Users/mottelet/Desktop/scilab-2024.0.0 (x86_64).app/Contents/share/scilab/modules/optimization/macros/leastsq.sci line 104 )

Operator *: Wrong dimensions for operation [7x1] * [7x1].