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

Index Out of Bounds Panic on array length comparison #1

Open
EmmaLouise2018 opened this issue Jul 22, 2019 · 0 comments
Open

Index Out of Bounds Panic on array length comparison #1

EmmaLouise2018 opened this issue Jul 22, 2019 · 0 comments

Comments

@EmmaLouise2018
Copy link

EmmaLouise2018 commented Jul 22, 2019

In index.go there is the function hasPrefix()

func (o *IndexDef) hasPrefix(columns []string) bool {
     if len(o.Columns) < len(columns) {
         return false
     }
 
     for i := range o.Columns {
         if o.Columns[i] != columns[i] {
             return false
         }
     }
     return true
 }

This causes an index out of bounds exception if the length of o.Columns is longer than that of columns since we are iterating through o.Columns in the for loop.

This check should be if len(o.Columns) > len(columns) to make sure we are not iterating through the longer array.

After making this change, all the tests continue to pass as expected.

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

No branches or pull requests

1 participant