From cab21782b4bb80ce7f9fa4ea13857bc4fc725c02 Mon Sep 17 00:00:00 2001 From: Jeremy Latt Date: Thu, 10 Apr 2014 11:53:34 -0700 Subject: [PATCH] fix crash in whowas circular buffer --- irc/constants.go | 2 +- irc/whowas.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/irc/constants.go b/irc/constants.go index cb604680..273c8ef8 100644 --- a/irc/constants.go +++ b/irc/constants.go @@ -1,7 +1,7 @@ package irc const ( - SEM_VER = "ergonomadic-1.4.2" + SEM_VER = "ergonomadic-1.4.3" CRLF = "\r\n" MAX_REPLY_LEN = 512 - len(CRLF) diff --git a/irc/whowas.go b/irc/whowas.go index e1a4686c..b8c4b2f2 100644 --- a/irc/whowas.go +++ b/irc/whowas.go @@ -2,8 +2,8 @@ package irc type WhoWasList struct { buffer []*WhoWas - start uint - end uint + start int + end int } type WhoWas struct { @@ -26,9 +26,9 @@ func (list *WhoWasList) Append(client *Client) { hostname: client.hostname, realname: client.realname, } - list.end = (list.end + 1) % uint(len(list.buffer)) + list.end = (list.end + 1) % len(list.buffer) if list.end == list.start { - list.start = (list.end + 1) % uint(len(list.buffer)) + list.start = (list.end + 1) % len(list.buffer) } } @@ -46,10 +46,10 @@ func (list *WhoWasList) Find(nickname Name, limit int64) []*WhoWas { return results } -func (list *WhoWasList) prev(index uint) uint { +func (list *WhoWasList) prev(index int) int { index -= 1 if index < 0 { - index += uint(len(list.buffer)) + index += len(list.buffer) } return index }