Skip to content

Commit

Permalink
fix: Fix some false positive from PVS Studio.
Browse files Browse the repository at this point in the history
It correctly warns about potentially dereferencing NULL chat in a log
statement. However, chat can semantically never be NULL in that call,
and it's just a defensive check. Still good to fix for clarity.
  • Loading branch information
iphydf committed Feb 9, 2024
1 parent 7c44379 commit 9fe18b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion other/docker/sources/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ if [ -f "$DOCKERDIR/dockerignore" ]; then
cat "$DOCKERDIR/dockerignore" >>"$DOCKERDIR/$BUILD.Dockerfile.dockerignore"
fi

docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
docker build "${DOCKERFLAGS[@]}" -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" .
6 changes: 3 additions & 3 deletions toxcore/group_chats.c
Original file line number Diff line number Diff line change
Expand Up @@ -5560,12 +5560,12 @@ static int make_gc_handshake_packet(const GC_Chat *chat, const GC_Connection *gc
uint8_t request_type, uint8_t join_type, uint8_t *packet, size_t packet_size,
const Node_format *node)
{
if (packet_size != GC_MIN_ENCRYPTED_HS_PAYLOAD_SIZE + sizeof(Node_format)) {
LOGGER_FATAL(chat->log, "invalid packet size: %zu", packet_size);
if (chat == nullptr || gconn == nullptr || node == nullptr) {
return -1;
}

if (chat == nullptr || gconn == nullptr || node == nullptr) {
if (packet_size != GC_MIN_ENCRYPTED_HS_PAYLOAD_SIZE + sizeof(Node_format)) {
LOGGER_FATAL(chat->log, "invalid packet size: %zu", packet_size);

Check warning on line 5568 in toxcore/group_chats.c

View check run for this annotation

Codecov / codecov/patch

toxcore/group_chats.c#L5568

Added line #L5568 was not covered by tests
return -1;
}

Expand Down

0 comments on commit 9fe18b1

Please sign in to comment.