Skip to content

Commit daf483d

Browse files
committed
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.
1 parent e38cd60 commit daf483d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cmd/ksh93/sh/array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ static struct index_array *array_grow(Namval_t *np, register struct index_array
819819
errormsg(SH_DICT,ERROR_exit(1),e_subscript, fmtbase((long)maxi,10,0));
820820
UNREACHABLE();
821821
}
822-
i = (newsize-1)*sizeof(union Value*)+newsize;
822+
i = (newsize-1)*sizeof(union Value)+newsize;
823823
ap = new_of(struct index_array,i);
824824
memset((void*)ap,0,sizeof(*ap)+i);
825825
ap->maxi = newsize;

0 commit comments

Comments
 (0)