Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix slice bounds out of range error on remove host entries #46

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

evidolob
Copy link
Contributor

Fix deleting host entries: panic: runtime error: slice bounds out of range [4:3]

The problem was in iterating over array which we modify(remove items from it)

for hostIdx, hostname := range line.Hostnames {
if _, ok := hostEntries[hostname]; ok {
h.removeHostFromLine(line, hostIdx, i)
for _, hostToRemove := range hosts {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@@ -234,6 +234,18 @@ func TestRemoveOnOldHostFile(t *testing.T) {
assert.Equal(t, hostsTemplate, string(content))
}

func TestDeleteSliceBoundErrorOnRemove(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@praveenkumar praveenkumar merged commit e336a9e into crc-org:master Dec 14, 2023
1 check passed
@cfergeau
Copy link
Contributor

Details about what was causing the bug and how it was fixed is always useful to have in a commit log, for better review, for easier understanding when we get back to this code, ...
1 line commit log are only appropriate for trivial / very obvious commits.

@evidolob evidolob deleted the fix-slice-bound-error branch December 14, 2023 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants