Closed rafal-c closed 5 years ago
Unfortunately the proposed fix is not sufficient, since there can be variables that are excluded by the directory, see e.g., https://github.com/tbeu/matio/blob/8523c5ed5e03c0523f6ecd1f407fc8a128e8ab29/src/mat73.c#L2711-L2713
Resolved by e697a0a8a238b773f20b432c3a58dd4f53f85e62. Thanks for reporting.
In the code below:
names
andn
will have correct values when this code is evaluated for the first time for a givenmatFile
but all subsequent evaluations will leaven
uninitialized.This is because apart from the first evaluation of
Mat_GetDir
the check in mat.c:579 will be false and we jump directly to mat.c:649 which only initializesdir
butn
is untouched through the whole function execution path. Adding*n = mat->num_datasets;
in L650 is the simplest fix that comes to mind.