Skip to content

Commit

Permalink
Avoid array subscript error when checking OpenSSL versions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mislav committed Nov 5, 2024
1 parent 281e598 commit bc88537
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bin/ruby-build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bc88537

Please sign in to comment.