Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix panic at launch when current song does not have lyrics #65

Merged

Conversation

denisdubochevalier
Copy link
Contributor

When launching mpdlrc while playing a song without associated lrc file, the following panic occurs:

$ mpdlrc
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x58e454]

goroutine 1 [running]:
github.com/env25/mpdlrc/internal/lyrics.(*Lyrics).check(...)
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/lyrics/lyrics.go:20
github.com/env25/mpdlrc/internal/lyrics.(*Lyrics).Sort(...)
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/lyrics/lyrics.go:43
github.com/env25/mpdlrc/internal/client.(*MPDClient).lyrics(0xc000227700, {0x65fc90, 0xc0008d0000})
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/client/mpdclient.go:168 +0xf4
github.com/env25/mpdlrc/internal/client.(*MPDClient).Data(0xc000227700)
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/client/mpdclient.go:145 +0x558
github.com/env25/mpdlrc/internal.(*Application).updateResize(0xc000278000, {0x65ee50, 0xc00009c050}, {0x65e188, 0xc00022e000}, 0x105, 0x6e)
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/app.go:106 +0x15c
github.com/env25/mpdlrc/internal.(*Application).update(0xc000278000, {0x65ee50, 0xc00009c050}, {0x65e188?, 0xc00022e000})
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/app.go:83 +0x479
github.com/env25/mpdlrc/internal.(*Application).Run(0xc000278000, {0x65ede0, 0x851380})
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/app.go:145 +0x4f0
main.maine()
	/home/denis/Clone/github.com/eNV25/mpdlrc/main.go:81 +0x27e
main.main()
	/home/denis/Clone/github.com/eNV25/mpdlrc/main.go:98 +0x5a

I fix it by bypassing the call to lrc.Sort() when lrc is nil.

When launching mpdlrc while playing a song without associated lrc
file, the following panic occurs:

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x58e454]

goroutine 1 [running]:
github.com/env25/mpdlrc/internal/lyrics.(*Lyrics).check(...)
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/lyrics/lyrics.go:20
github.com/env25/mpdlrc/internal/lyrics.(*Lyrics).Sort(...)
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/lyrics/lyrics.go:43
github.com/env25/mpdlrc/internal/client.(*MPDClient).lyrics(0xc000227700, {0x65fc90, 0xc0008d0000})
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/client/mpdclient.go:168 +0xf4
github.com/env25/mpdlrc/internal/client.(*MPDClient).Data(0xc000227700)
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/client/mpdclient.go:145 +0x558
github.com/env25/mpdlrc/internal.(*Application).updateResize(0xc000278000, {0x65ee50, 0xc00009c050}, {0x65e188, 0xc00022e000}, 0x105, 0x6e)
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/app.go:106 +0x15c
github.com/env25/mpdlrc/internal.(*Application).update(0xc000278000, {0x65ee50, 0xc00009c050}, {0x65e188?, 0xc00022e000})
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/app.go:83 +0x479
github.com/env25/mpdlrc/internal.(*Application).Run(0xc000278000, {0x65ede0, 0x851380})
	/home/denis/Clone/github.com/eNV25/mpdlrc/internal/app.go:145 +0x4f0
main.maine()
	/home/denis/Clone/github.com/eNV25/mpdlrc/main.go:81 +0x27e
main.main()
	/home/denis/Clone/github.com/eNV25/mpdlrc/main.go:98 +0x5a
```

I fix it by bypassing the call to `lrc.Sort()` when `lrc` is `nil`.
@eNV25 eNV25 merged commit c819a35 into eNV25:master May 13, 2024
@eNV25
Copy link
Owner

eNV25 commented May 13, 2024

Thanks! Good to see people actually use this.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants