From e5bce700a904734778a3683bd5d59f1862e97dae Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 16 Apr 2023 21:22:08 +0200 Subject: [PATCH] Panic if isHighlight is called with empty nick Let's make sure callers never do this. We'd go into an infinite loop previously. --- irc.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/irc.go b/irc.go index 0e2c069..dbad3b1 100644 --- a/irc.go +++ b/irc.go @@ -228,6 +228,10 @@ func isWordBoundary(r rune) bool { } func isHighlight(text, nick string) bool { + if len(nick) == 0 { + panic("isHighlight called with empty nick") + } + for { i := strings.Index(text, nick) if i < 0 {