Skip to content

Commit

Permalink
array_grow(): fix wrong sizeof()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
McDutchie committed Jan 30, 2022
1 parent 39673b1 commit 9e525c5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cmd/ksh93/sh/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
UNREACHABLE();
}
i = (newsize-1)*sizeof(union Value*)+newsize;
i = (newsize-1)*sizeof(union Value)+newsize;
ap = new_of(struct index_array,i);
memset((void*)ap,0,sizeof(*ap)+i);
ap->maxi = newsize;
Expand Down

0 comments on commit 9e525c5

Please sign in to comment.