rakslice / twitch-notifier-go

A golang port of my twitch.tv desktop notifier; for Windows and Mac; not maintained
https://twitch-notifier.blogspot.com
Other
0 stars 0 forks source link

null deref during paged kraken #1

Closed rakslice closed 7 years ago

rakslice commented 7 years ago
2016/12/06 19:44:57 pagedKraken for [streams followed] loading entries 0 to 25
2016/12/06 19:44:57 GET https://api.twitch.tv/kraken/streams/followed?limit=25&offset=0
2016/12/06 19:44:57 pagedKraken processing key error
2016/12/06 19:44:57 pagedKraken processing key status
2016/12/06 19:44:57 pagedKraken processing key message
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x110 pc=0x4a8e92]

goroutine 1 [running]:
panic(0x9e0260, 0xc04200e0b0)
    C:/Go/src/runtime/panic.go:500 +0x1af
encoding/json.(*Decoder).peek(0x0, 0xc04227ca28, 0x9c88a0, 0xc04227ca50)
    C:/Go/src/encoding/json/stream.go:485 +0x32
encoding/json.(*Decoder).More(0x0, 0x0)
    C:/Go/src/encoding/json/stream.go:478 +0x32
main.(*Kraken).PagedKraken(0xc04202a028, 0xa8b614, 0x7, 0x19, 0xc042324680, 0x2, 0x2, 0xf, 0x0, 0x4)
    C:/Users/Andrew Tonner/Documents/twitch-notifier-go/src/twitchnotifier/kraken.go:258 +0x153
main.(*TwitchNotifierMain).get_streams_channels_following(0xc042056a00, 0xc0420d71a0, 0x1)
    C:/Users/AndrewTonner/Documents/twitch-notifier-go/src/twitchnotifier/main.go:1063 +0x10f
main.(*ChannelWatcher).next(0xc0420e4100, 0x13, 0x0, 0x0)
    C:/Users/AndrewTonner/Documents/twitch-notifier-go/src/twitchnotifier/main.go:1238 +0x14e
main.(*OurTwitchNotifierMain).set_next_time(0xc042056a00)
    C:/Users/AndrewTonner/Documents/twitch-notifier-go/src/twitchnotifier/main.go:1387 +0x6e
main.(*OurTwitchNotifierMain).(main.set_next_time)-fm()
    C:/Users/AndrewTonner/Documents/twitch-notifier-go/src/twitchnotifier/main.go:1389 +0x31
main.(*MainStatusWindowImpl)._timer_internal_callback(0xc0420b8000)
    C:/Users/AndrewTonner/Documents/twitch-notifier-go/src/twitchnotifier/main.go:529 +0x3d
main.(*MainStatusWindowImpl).(main._timer_internal_callback)-fm()
    C:/Users/AndrewTonner/Documents/twitch-notifier-go/src/twitchnotifier/main.go:509 +0x31
main.(*WxTimeHelper).on_thread_event(0xc042006fc0, 0x1d97fe0, 0xc04227c990)
    C:/Users/AndrewTonner/Documents/twitch-notifier-go/src/twitchnotifier/main.go:453 +0x8a
main.(*WxTimeHelper).(main.on_thread_event)-fm(0x1d97fe0, 0xc04227c990)
    C:/Users/AndrewTonner/Documents/twitch-notifier-go/src/twitchnotifier/main.go:413 +0x45
github.com/dontpanic92/wxGo/wx.(*goCallbackDispatcherClass).Callback(0x21f00b8, 0x1d97fe0, 0xc04227c990)
    C:/Users/AndrewTonner/Documents/twitch-notifier-gopath/src/github.com/dontpanic92/wxGo/wx/wx_windows.go:21522 +0xa9
github.com/dontpanic92/wxGo/wx.(*_swig_DirectorGoCallbackDispatcher).Callback(0xc04205b920, 0x1d8d700, 0xc04227c990)
    C:/Users/AndrewTonner/Documents/twitch-notifier-gopath/src/github.com/dontpanic92/wxGo/wx/wx_windows.go:33008 +0xc4
github.com/dontpanic92/wxGo/wx.Swig_DirectorGoCallbackDispatcher_callback_Callback_wx_76157d0b1a729e64(0x1, 0x664aae0)
    C:/Users/AndrewTonner/Documents/twitch-notifier-gopath/src/github.com/dontpanic92/wxGo/wx/wx_windows.go:33017 +0x83
github.com/dontpanic92/wxGo/wx._cgoexpwrap_09f5cb87f156_Swig_DirectorGoCallbackDispatcher_callback_Callback_wx_76157d0b1a729e64(0x1, 0x664aae0)
    ??:0 +0x3c
github.com/dontpanic92/wxGo/wx._Cfunc__wrap_App_MainLoop_wx_76157d0b1a729e64(0x661e720, 0x0)
    ??:0 +0x55
github.com/dontpanic92/wxGo/wx.SwigClassApp.MainLoop(0x661e720, 0x12)
    C:/Users/AndrewTonner/Documents/twitch-notifier-gopath/src/github.com/dontpanic92/wxGo/wx/wx_windows.go:22956 +0x5c
github.com/dontpanic92/wxGo/wx.(*SwigClassApp).MainLoop(0xc04200f450, 0x12)
    <autogenerated>:130 +0x59
main.commonMain()
    C:/Users/AndrewTonner/Documents/twitch-notifier-go/src/twitchnotifier/main.go:1425 +0x1a8
main.main()
    C:/Users/Andrew Tonner/Documents/twitch-notifier-go/src/twitchnotifier/main_windows.go:26 +0x1b
rakslice commented 7 years ago

There was a null deref possible when the response was missing the expected list field.

In this case the response was an authentication failure with an HTTP error status 401 (and the fact it was a twitch API error is indicated here by the presence of the error field). PagedKraken was missing an HTTP error check.

Since this I've: