Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix nil pointer dereference when TCP listener is configured #34

Merged

Conversation

edwinbalani
Copy link
Contributor

@edwinbalani edwinbalani commented Mar 31, 2024

After 60526f6 (#31),
irccat.tcp.Run(irccat.irc) is called (if the config calls for it)
before, rather than after, irccat.connectIRC(), which changes
irccat.irc away from a nil pointer in the first place. This pointer
is copied into the irc field of a TCPListener l by
irccat.tcp.Run().

A panic won't actually happen until the TCP listener handles its first
message, if it ever comes, and in doing so passes the nil pointer
further down to dispatcher.Send(l.irc, ...).

To fix, bring the call to irccat.connectIRC() forward again, to before
any listener setup is done at all. This probably makes sense
stylistically too.

After 60526f6 (irccloud#31),
`irccat.tcp.Run(irccat.irc)` is called (if the config calls for it)
before, rather than after, `irccat.connectIRC()`, which changes
`irccat.irc` away from a nil pointer in the first place.  This pointer
is copied into the `irc` field of a TCPListener `l` by
`irccat.tcp.Run()`.

A panic won't actually happen until the TCP listener handles its first
message, if it ever comes, and in doing so passes the nil pointer
further down to `dispatcher.Send(l.irc, ...)`.

To fix, bring the call to `irccat.connectIRC()` forward again, to before
any listener setup is done at all.  This probably makes sense
stylistically too.
@russss russss merged commit 20f0ffb into irccloud:master Apr 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants