spa: audioconvert: fix allocation size calculation

Currently, the code allocates

  sizeof(header) * sizeof(item) * n_items

bytes instead of the more appropriate

  sizeof(header) + sizeof(item) * n_items

Fix that by simply changing the first multiplication to addition, and
furthermore, use a flexible array member instead of a zero-sized array.

Found by clang-tidy.
This commit is contained in:
Barnabás Pőcze 2022-01-18 21:10:31 +01:00
parent 6515553b7d
commit d2114c3f2e
2 changed files with 2 additions and 2 deletions

View file

@ -146,7 +146,7 @@ int resample_peaks_init(struct resample *r)
r->delay = impl_peaks_delay;
r->in_len = impl_peaks_in_len;
d = r->data = calloc(1, sizeof(struct peaks_data) * sizeof(float) * r->channels);
d = r->data = calloc(1, sizeof(struct peaks_data) + sizeof(float) * r->channels);
if (r->data == NULL)
return -errno;