Skip to content

Commit

Permalink
Fix #13026 (Fix Coverity issues) (danmar#6710)
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Aug 21, 2024
1 parent 2c2d504 commit 426c621
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/checkunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ bool CheckUnusedVar::isRecordTypeWithoutSideEffects(const Type* type)
continue; // ignore default/deleted constructors
const bool emptyBody = (f.functionScope && Token::simpleMatch(f.functionScope->bodyStart, "{ }"));

const Token* nextToken = f.argDef->link();
const Token* nextToken = f.argDef ? f.argDef->link() : nullptr;
if (Token::simpleMatch(nextToken, ") :")) {
// validating initialization list
nextToken = nextToken->next(); // goto ":"
Expand Down
3 changes: 2 additions & 1 deletion lib/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ std::string Path::getCurrentExecutablePath(const char* fallback)
#else // Linux
"/proc/self/exe";
#endif
success = (readlink(procPath, buf, sizeof(buf)) != -1);
// readlink does not null-terminate the string if the buffer is too small, therefore write bufsize - 1
success = (readlink(procPath, buf, sizeof(buf) - 1) != -1);
#endif
return success ? std::string(buf) : std::string(fallback);
}
Expand Down

0 comments on commit 426c621

Please sign in to comment.