From 4b12c0dc3c5ab5efb140ff478989daee47e1c7fa Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Mon, 23 Jun 2025 22:52:34 +0100 Subject: [PATCH] Fix nullptr dereference If client sends TAGMSG while server is not connected --- src/Client.cpp | 2 +- test/integration/tests/core.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Client.cpp b/src/Client.cpp index b3753e28..4da46f34 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -1657,7 +1657,7 @@ bool CClient::OnTagMessage(CTargetMessage& Message) { if (m_pNetwork) { AddBuffer(Message); EchoMessage(Message); - if (GetIRCSock()->HasMessageTagCap()) { + if (GetIRCSock() && GetIRCSock()->HasMessageTagCap()) { PutIRCStripping(Message); } } diff --git a/test/integration/tests/core.cpp b/test/integration/tests/core.cpp index 9e1171d0..0a56ba72 100644 --- a/test/integration/tests/core.cpp +++ b/test/integration/tests/core.cpp @@ -1210,5 +1210,16 @@ TEST_F(ZNCTest, Issue1960) { ircd2.ReadUntil("@foo TAGMSG #bar"); } +TEST_F(ZNCTest, DisconnectedTagmsgCrash) { + auto znc = Run(); + auto ircd = ConnectIRCd(); + auto client = LoginClient(); + client.Write("znc disconnect"); + client.ReadUntil("Disconnected"); + client.Write("@foo TAGMSG #foo"); + client.Write("znc help"); + client.ReadUntil("AddServer"); +} + } // namespace } // namespace znc_inttest