From b8afed6e1b36f4e6831f247a26941cd7cc2a3da8 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sat, 7 Oct 2023 05:34:50 +0400 Subject: [PATCH] In PlaylistNext() CheckAndUpdateMostListenedSong() call was moved after songList.Add to avoid nil pointer dereferencing. --- internal/http/dj_handlers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/http/dj_handlers.go b/internal/http/dj_handlers.go index cfb12fd..891f5c5 100644 --- a/internal/http/dj_handlers.go +++ b/internal/http/dj_handlers.go @@ -65,8 +65,8 @@ func (dj *DJHandlers) PlaylistNext(w http.ResponseWriter, _ *http.Request) { Duration: oggf.GetDuration(), MaxListeners: dj.listeners.Current(), StartAt: time.Now()} - radio.CheckAndUpdateMostListenedSong(*dj.songList.Current()) dj.songList.Add(song) + radio.CheckAndUpdateMostListenedSong(*dj.songList.Current()) }() } fmt.Fprintln(w, nxt)