reallocarray when reallocarraying

This commit is contained in:
наб 2024-03-05 19:19:40 +01:00
parent 52a4871ce0
commit a77e6c1d80
No known key found for this signature in database
GPG Key ID: BCFD0B018D2658F1

View File

@ -129,10 +129,9 @@ int main(int argc, char ** argv) {
TRY_MAIN(lookup_userprop(dataset, PROPNAME_BACKEND, backend));
TRY_MAIN(lookup_userprop(dataset, PROPNAME_KEY, handle));
++lines_len;
lines = TRY_PTR("allocate line buffer", reinterpret_cast<output_line *>(realloc(lines, sizeof(output_line) * lines_len)));
lines = TRY_PTR("allocate line buffer", reinterpret_cast<output_line *>(reallocarray(lines, ++lines_len, sizeof(output_line))));
auto & cur_line = lines[lines_len - 1];
strncpy(cur_line.name, zfs_get_name(dataset), ZFS_MAX_DATASET_NAME_LEN);
strncpy(cur_line.backend, (backend && strlen(backend) <= TZPFMS_BACKEND_MAX_LEN) ? backend : "\0", TZPFMS_BACKEND_MAX_LEN);
// Tristate available/unavailable/none, but it's gonna be either available or unavailable on envryption roots, so