Skip to content

Commit

Permalink
Merge pull request #2322 from mavlink/pr-sonar-fixes
Browse files Browse the repository at this point in the history
Sonarcloud warnings
  • Loading branch information
julianoes authored Jun 1, 2024
2 parents 41523f7 + 96d218f commit 68f777a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/mavsdk/core/inflate_lzma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ static bool decompress(lzma_stream* strm, const char* inname, FILE* infile, FILE

if (ferror(infile)) {
fprintf(stderr, "%s: Read error: %s\n", inname, strerror(errno));
// SonarCloud: Address of stack memory associated with local
// variable 'inbuf' is still referred to by the stack variable
// 'strm' upon returning to the caller. This will be a
// dangling reference
// Fixed by setting to nullptr.
strm->next_in = nullptr;
strm->avail_in = 0;
strm->next_out = nullptr;
strm->avail_out = 0;
return false;
}

Expand Down Expand Up @@ -264,4 +273,4 @@ bool InflateLZMA::inflateLZMAFile(
lzma_end(&strm);

return success;
}
}
2 changes: 1 addition & 1 deletion src/mavsdk/core/mavlink_ftp_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class MavlinkFtpClient {

struct Work {
Item item;
PayloadHeader payload; // The last payload saved for retries
PayloadHeader payload{}; // The last payload saved for retries
unsigned retries{RETRIES};
bool started{false};
Opcode last_opcode{};
Expand Down

0 comments on commit 68f777a

Please sign in to comment.