Closed jamesjer closed 1 year ago
Sorry for the late reply.
We reviewed the situation and realized that the suitable way is to check the return of mxGetString. Please see the diff below. This is committed to the internal git and will be available here in the next release. Many thanks for pointing out the issue.
diff --git a/matlab/libsvmread.c b/matlab/libsvmread.c index 21291df..9c5bf43 100644 --- a/matlab/libsvmread.c +++ b/matlab/libsvmread.c @@ -188,7 +188,9 @@ void read_problem(const char filename, int nlhs, mxArray plhs[]) void mexFunction( int nlhs, mxArray plhs[], int nrhs, const mxArray prhs[] ) {
char filename[256];
char filename[filename_size];
if(nrhs != 1 || nlhs != 2) { @@ -197,11 +199,9 @@ void mexFunction( int nlhs, mxArray *plhs[], return; }
mxGetString(prhs[0], filename, mxGetN(prhs[0]) + 1);
if(filename == NULL)
{
mexPrintf("Error: filename is NULL\n");
if(mxGetString(prhs[0], filename, filename_size) == 1){
mexPrintf("Error: wrong or too long filename\n");
fake_answer(nlhs, plhs); return; }
GCC says: