From 973fa5974007a7b56d5e837020563b9f9dbed11c Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Fri, 15 Nov 2024 11:46:01 -0500 Subject: [PATCH] add extra error handling and check if the lookup tables are available before attempting to process; --- src/fne/network/PeerNetwork.cpp | 15 +++++++++++++++ src/sysview/network/PeerNetwork.cpp | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/fne/network/PeerNetwork.cpp b/src/fne/network/PeerNetwork.cpp index b66446ff..0339105a 100644 --- a/src/fne/network/PeerNetwork.cpp +++ b/src/fne/network/PeerNetwork.cpp @@ -193,6 +193,11 @@ void PeerNetwork::userPacketHandler(uint32_t peerId, FrameQueue::OpcodePair opco // check that we got the appropriate data if (decompressedLen == m_tgidSize) { + if (m_tidLookup == nullptr) { + LogError(LOG_NET, "Talkgroup ID lookup not available yet."); + goto tid_lookup_cleanup; // yes - I hate myself; but this is quick + } + // store to file std::unique_ptr __str = std::make_unique(decompressedLen + 1U); char* str = __str.get(); @@ -325,6 +330,11 @@ void PeerNetwork::userPacketHandler(uint32_t peerId, FrameQueue::OpcodePair opco // check that we got the appropriate data if (decompressedLen == m_ridSize) { + if (m_ridLookup == nullptr) { + LogError(LOG_NET, "Radio ID lookup not available yet."); + goto rid_lookup_cleanup; // yes - I hate myself; but this is quick + } + // store to file std::unique_ptr __str = std::make_unique(decompressedLen + 1U); char* str = __str.get(); @@ -457,6 +467,11 @@ void PeerNetwork::userPacketHandler(uint32_t peerId, FrameQueue::OpcodePair opco // check that we got the appropriate data if (decompressedLen == m_pidSize) { + if (m_pidLookup == nullptr) { + LogError(LOG_NET, "Peer ID lookup not available yet."); + goto pid_lookup_cleanup; // yes - I hate myself; but this is quick + } + // store to file std::unique_ptr __str = std::make_unique(decompressedLen + 1U); char* str = __str.get(); diff --git a/src/sysview/network/PeerNetwork.cpp b/src/sysview/network/PeerNetwork.cpp index 29f73048..1de24f5d 100644 --- a/src/sysview/network/PeerNetwork.cpp +++ b/src/sysview/network/PeerNetwork.cpp @@ -209,6 +209,11 @@ void PeerNetwork::userPacketHandler(uint32_t peerId, FrameQueue::OpcodePair opco // check that we got the appropriate data if (decompressedLen == m_tgidSize) { + if (m_tidLookup == nullptr) { + LogError(LOG_NET, "Talkgroup ID lookups not available yet."); + goto tid_lookup_cleanup; // yes - I hate myself; but this is quick + } + // store to file std::unique_ptr __str = std::make_unique(decompressedLen + 1U); char* str = __str.get(); @@ -341,6 +346,11 @@ void PeerNetwork::userPacketHandler(uint32_t peerId, FrameQueue::OpcodePair opco // check that we got the appropriate data if (decompressedLen == m_ridSize) { + if (m_ridLookup == nullptr) { + LogError(LOG_NET, "Radio ID lookups not available yet."); + goto rid_lookup_cleanup; // yes - I hate myself; but this is quick + } + // store to file std::unique_ptr __str = std::make_unique(decompressedLen + 1U); char* str = __str.get();