Skip to content

Comments

Fix index out of range#1

Open
yusuke-koyoshi wants to merge 2 commits intocloud-maker-ai:mainfrom
yusuke-koyoshi:fix-bug
Open

Fix index out of range#1
yusuke-koyoshi wants to merge 2 commits intocloud-maker-ai:mainfrom
yusuke-koyoshi:fix-bug

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/go-unique-string@v0.0.0-20221215222937-c55128876647/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/go-unique-string@v0.0.0-20221215222937-c55128876647/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