Skip to content

Fix index out of range #1

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

yusuke-koyoshi
Copy link

Fixed a bug where the index was out of range when the input string was short.

func main() {
	if len(os.Args) == 1 {
		_, _ = fmt.Fprintf(os.Stderr, "usage: %s string1 [string2]...\n", os.Args[0])
		os.Exit(1)
	}

	fmt.Printf("%s\n", unique_string.GenerateUniqueString(os.Args[1:]...))
}
$ ./go-azure-unique-string a a
panic: runtime error: index out of range [3] with length 3

goroutine 1 [running]:
github.com/cloud-maker-ai/go-unique-string.murmurHash64({0x14000090020?, 0x102f29088?, 0x2?})
	/Users/yusuke.koyoshi/go/pkg/mod/github.com/cloud-maker-ai/[email protected]/unique_string.go:56 +0x304
github.com/cloud-maker-ai/go-unique-string.GenerateUniqueString({0x140000a0070?, 0x0?, 0x1400005e738?})
	/Users/yusuke.koyoshi/go/pkg/mod/github.com/cloud-maker-ai/[email protected]/unique_string.go:113 +0x44
main.main()
	/Users/yusuke.koyoshi/ghq/test/go-azure-unique-string/main.go:18 +0x54

@berlincount
Copy link

I'd also need this fix to be applied, running into the same problem ...

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.

2 participants