Message.GetChan() is always NULL in OnUserTextMessage #766

Closed
opened 2026-10-05 04:43:26 +02:00 by adam · 1 comment
Owner

Version: ZNC 1.7.x-git-755-8b48465d

Steps to reproduce:

  1. Write a module which overrides CModule::OnUserTextMessage
  2. Send a message to a channel
  3. Observe that CModule::OnUserTextMessage is called with a CMessage whose GetChan() returns NULL.
Version: ZNC 1.7.x-git-755-8b48465d Steps to reproduce: 1. Write a module which overrides `CModule::OnUserTextMessage` 2. Send a message to a channel 3. Observe that `CModule::OnUserTextMessage` is called with a `CMessage` whose `GetChan()` returns `NULL`. <!-- github-sync-id:224717760 -->
adam closed this issue 2026-10-05 04:43:26 +02:00
Author
Owner

That's because the old non-CMessage version of this callback didn't have CChan. But it makes sense to fill it when possible, yeah; the same for other functions.
This will introduce a caveat, that every module which uses GetChan() needs to check for nullptr. In some cases almost all calls of the callback are not nullptr, so the module writer can miss such check.

That's because the old non-CMessage version of this callback didn't have CChan. But it makes sense to fill it when possible, yeah; the same for other functions. This will introduce a caveat, that every module which uses GetChan() needs to check for nullptr. In some cases almost all calls of the callback are not nullptr, so the module writer can miss such check. <!-- github-comment-id:298442194 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#766