mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
[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:
parent
26cd93f788
commit
16c6818612
1 changed files with 4 additions and 0 deletions
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue