tbeu / matio

MATLAB MAT File I/O Library
https://matio.sourceforge.io
BSD 2-Clause "Simplified" License
338 stars 97 forks source link

[REGRESSION v1.5.14] Mat_GetDir raises an exception about Mat_VarFree #108

Closed Nelson-numerical-software closed 5 years ago

Nelson-numerical-software commented 5 years ago

Moving my code from 1.5.13 to 1.5.14, I have one test fails with matio 1.5.14. load cell seems to raise an exception

here test:

matver = { '-v7', '-v7.3'};
R_REF = {'Nelson' 'supports'; 'string' 'array'};
for v = matver
  test_file_mat = ['d:/test_save_char_vector', v{1}, '.mat'];
  R = {'Nelson' 'supports'; 'string' 'array'};
  save(test_file_mat, 'R', v{1});
  clear R
  load(test_file_mat)
end

attached generated .mat files for -v7 & -v7.3

test_save_cell-v1.5.14.zip

When we try to open theses files

C/C++ :

  std::string utf8filename = wstring_to_utf8(filename);
    mat_t* matfile = Mat_Open(utf8filename.c_str(), MAT_ACC_RDONLY);

    stringVector variableNamesInFile;
    size_t nVars = 0;
    char** variableNames = Mat_GetDir(matfile, &nVars);

Mat_GetDir raises an exception about Mat_VarFree

image

From emails exchanged with @tbeu , it seems that this problem was added by this commit https://github.com/tbeu/matio/commit/a0539135c9b1ab7613aa7953279da9224da88775

tbeu commented 5 years ago

@Nelson-numerical-software Can you please confirm that adfa218770183cf93f74e7fad5055921ae1f9958 fixes the issue? Thanks.

Nelson-numerical-software commented 5 years ago

Hi,

Currently I checked on Win32 and windows X64 and debian 9 x64 target and it works with adfa218.

--> test_run matio
 1/1 - [matio] :
 01/28 - [matio] test_ismatfile                                             Pass
 02/28 - [matio] test_loadmat_cell                                          Pass
 03/28 - [matio] test_loadmat_char                                          Pass
 04/28 - [matio] test_loadmat_double                                        Pass
 05/28 - [matio] test_loadmat_empty                                         Pass
 06/28 - [matio] test_loadmat_empty_cell                                    Pass
 07/28 - [matio] test_loadmat_function_handle                               Pass
 08/28 - [matio] test_loadmat_integers                                      Pass
 09/28 - [matio] test_loadmat_logical                                       Pass
 10/28 - [matio] test_loadmat_object                                        Pass
 11/28 - [matio] test_loadmat_sparse_double                                 Pass
 12/28 - [matio] test_loadmat_sparse_logical                                Pass
 13/28 - [matio] test_loadmat_struct                                        Pass
 14/28 - [matio] test_savemat_cell                                          Pass
 15/28 - [matio] test_savemat_char                                          Pass
 16/28 - [matio] test_savemat_double                                        Pass
 17/28 - [matio] test_savemat_function_handle                               Pass
 18/28 - [matio] test_savemat_handle                                        Pass
 19/28 - [matio] test_savemat_integers                                      Pass
 20/28 - [matio] test_savemat_logical                                       Pass
 21/28 - [matio] test_savemat_object                                        Pass
 22/28 - [matio] test_savemat_single                                        Pass
 23/28 - [matio] test_savemat_sparse_double                                 Pass
 24/28 - [matio] test_savemat_sparse_logical                                Pass
 25/28 - [matio] test_savemat_string_array                                  Pass
 26/28 - [matio] test_savemat_struct                                        Pass
 27/28 - [matio] test_whomat                                                Pass
 28/28 - [matio] test_whosmat                                               Pass

  //==========================================================================
  Summary:
  Tests: 28
  Passed: 28
  Failed: 0
  Skipped: 0
  Benchs: 0
  Tests time: 6.1 s 
  Total time: 7.5 s 
  //===========================================================================