1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-07-22 18:57:39 +02:00

fix leaking memory [front]

This commit is contained in:
q-posev 2021-06-14 16:27:08 +02:00
parent 5553e9110e
commit eadc2c63ac

View File

@ -1583,7 +1583,7 @@ trexio_read_$group_dset$ (trexio_t* const file, char** dset, const uint32_t max_
if (dset_dim == 0L) return TREXIO_INVALID_NUM; if (dset_dim == 0L) return TREXIO_INVALID_NUM;
char* str_compiled = CALLOC(dset_dim*max_str_len + 1, char); char* str_compiled = CALLOC(dset_dim*(max_str_len+1) + 1, char);
if (str_compiled == NULL) return TREXIO_ALLOCATION_FAILED; if (str_compiled == NULL) return TREXIO_ALLOCATION_FAILED;
rc = trexio_read_$group_dset$_low(file, str_compiled, max_str_len); rc = trexio_read_$group_dset$_low(file, str_compiled, max_str_len);
@ -1601,7 +1601,8 @@ trexio_read_$group_dset$ (trexio_t* const file, char** dset, const uint32_t max_
return TREXIO_FAILURE; return TREXIO_FAILURE;
} }
strncpy(dset[i], pch, max_str_len+1); strcpy(dset[i], "");
strcat(dset[i], pch);
} }