From bc88537fc5a3a773b5e46082bc92b1f4fa0123a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 5 Nov 2024 14:42:53 +0100 Subject: [PATCH] Avoid array subscript error when checking OpenSSL versions If none of Homebrew OpenSSL versions satisfy the `needs_openssl` requirement, array iteration will reach `index=-1` and that will raise a non-fatal error when accessing the `versions` array. This makes sure not to go past index=0. --- bin/ruby-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ruby-build b/bin/ruby-build index 3e6ddef103..332be35176 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -1154,7 +1154,7 @@ needs_openssl() { # shellcheck disable=SC2207 versions=( $(awk '{print $2}' <<<"$brew_installs" | sort_versions) ) local index="${#versions[@]}" - while [ $((index--)) -ge 0 ]; do + while [ $((--index)) -ge 0 ]; do homebrew_version="$(normalize_semver "${versions[index]}")" (( homebrew_version >= lower_bound && homebrew_version < upper_bound )) || continue while read -r formula version prefix; do