[pacman-dev] [PATCH] makepkg: clear destination array in array_build

Allan McRae allan at archlinux.org
Mon Jan 12 02:50:46 UTC 2015

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

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

Signed-off-by: Allan McRae <allan at archlinux.org>
 scripts/makepkg.sh.in | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 1720e64..00beb76 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -2467,6 +2467,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

More information about the pacman-dev mailing list