derekparker / trie

Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching.
MIT License
748 stars 114 forks source link

Fix panic during searches when trie is empty #33

Closed arussellk closed 1 year ago

arussellk commented 1 year ago

make([]T, len, cap) panics if len > cap. The offending slice is already hardcoded to have starting length 1, so this change is the simplest way to ensure that the capacity is always valid. Per https://pkg.go.dev/builtin#make:

A second integer argument may be provided to specify a different capacity; it must be no smaller than the length.

This fixes the issue described by https://github.com/go-delve/delve/issues/3217.