Skip to content

Commit

Permalink
add extra error handling and check if the lookup tables are available…
Browse files Browse the repository at this point in the history
… before attempting to process;
  • Loading branch information
gatekeep committed Nov 15, 2024
1 parent dc5e156 commit 973fa59
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/fne/network/PeerNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char[]> __str = std::make_unique<char[]>(decompressedLen + 1U);
char* str = __str.get();
Expand Down Expand Up @@ -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<char[]> __str = std::make_unique<char[]>(decompressedLen + 1U);
char* str = __str.get();
Expand Down Expand Up @@ -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<char[]> __str = std::make_unique<char[]>(decompressedLen + 1U);
char* str = __str.get();
Expand Down
10 changes: 10 additions & 0 deletions src/sysview/network/PeerNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char[]> __str = std::make_unique<char[]>(decompressedLen + 1U);
char* str = __str.get();
Expand Down Expand Up @@ -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<char[]> __str = std::make_unique<char[]>(decompressedLen + 1U);
char* str = __str.get();
Expand Down

0 comments on commit 973fa59

Please sign in to comment.