makepkg: clear destination array in array_build

If an already used array is passed array_build, some entries from the old
array could be carried over if the old array was longer than the new one.
Clear the destination array before adding elements to it to prevent this
issue.

Fixes: https://bugs.archlinux.org/task/43387

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2015-01-12 12:47:38 +10:00
parent e8d757b6ba
commit a31426d3ea

View file

@ -2466,6 +2466,9 @@ array_build() {
# Build an array of the indicies of the source array.
eval "keys=(\"\${!$2[@]}\")"
# Clear the destination array
eval "$dest=()"
# Read values indirectly via their index. This approach gives us support
# for associative arrays, sparse arrays, and empty strings as elements.
for i in "${keys[@]}"; do