1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

array_grow(): fix wrong sizeof()

The array_grow() function calculates the size by multiplying with
sizeof(union Value*), where sizeof(union Value) was clearly meant.
In practice, these are the same size on most (or maybe even all)
systems, as no current member of union Value is larger than a
pointer -- see name.h. But it's still wrong.
This commit is contained in:
Martijn Dekker 2022-01-29 03:52:27 +00:00
parent 39673b1207
commit 9e525c5bde

View file

@ -819,7 +819,7 @@ static struct index_array *array_grow(Namval_t *np, register struct index_array
errormsg(SH_DICT,ERROR_exit(1),e_subscript, fmtbase((long)maxi,10,0)); errormsg(SH_DICT,ERROR_exit(1),e_subscript, fmtbase((long)maxi,10,0));
UNREACHABLE(); UNREACHABLE();
} }
i = (newsize-1)*sizeof(union Value*)+newsize; i = (newsize-1)*sizeof(union Value)+newsize;
ap = new_of(struct index_array,i); ap = new_of(struct index_array,i);
memset((void*)ap,0,sizeof(*ap)+i); memset((void*)ap,0,sizeof(*ap)+i);
ap->maxi = newsize; ap->maxi = newsize;