[util] Set parsed array size correctly

The array has to be allocated using byte elements and thus the size of
the array is the number of bytes, but it needs to be the actual number
of elements in the array. Problem caused by not knowing the actual type
(and C not having type variables anyway).
This commit is contained in:
Bill Currie 2020-07-16 22:05:15 +09:00
parent 26cd93f788
commit 16c6818612

View file

@ -1202,6 +1202,10 @@ PL_ParseArray (const plfield_t *field, const plitem_t *array, void *data,
arr = DARRAY_ALLOCFIXED (arr_t, plarray->numvals * element->stride,
element->alloc);
memset (arr->a, 0, arr->size);
// the array is allocated using bytes, but need the actual number of
// elements in the array
arr->size = arr->maxSize = plarray->numvals;
for (int i = 0; i < plarray->numvals; i++) {
plitem_t *item = plarray->values[i];