Skip to content

Commit

Permalink
patch: fix some UBs
Browse files Browse the repository at this point in the history
  • Loading branch information
dima424658 committed May 17, 2024
1 parent 43a86f9 commit ac67f2d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libsrc/cpptools/hashset.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ inline BOOL cHashSetBase::IsEmpty() const

inline tHashSetHandle cHashSetBase::FindIndex(tHashSetKey a) const
{
tHashSetHandle h;
tHashSetHandle h = {};
h.Index = Hash(a) % m_nPts;

h.pPrev = 0;
Expand Down
3 changes: 1 addition & 2 deletions libsrc/cpptools/splitpat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,7 @@ BOOL cPathSplitter::DoSplitTo(eComponent /* SplitToComponent */)
}
else
{
char buffer[256];
sprintf(buffer, "Drive not found (%d && %d)", !!(pScan >= pcszTarget), !!(*pScan == ':'));
sprintf(buffer, "Drive not found (%d && %d)", !!(pScan >= pcszTarget), !!(pScan >= pcszTarget && *pScan == ':'));
DebugStr(buffer);
Drive.IfNotFoundAssumeZeroLenAt(pEndDrive);
}
Expand Down
2 changes: 1 addition & 1 deletion libsrc/namedres/pathutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void GetNormalizedPath(const char* pOldPath, char** ppNewPath)
}

auto nameLen = strlen(pOldPath);
auto lastChar = pOldPath[nameLen - 1];
auto lastChar = nameLen ? pOldPath[nameLen - 1] : '\0';
auto needSlash = false;

if (lastChar != '\\' && lastChar != '/')
Expand Down

0 comments on commit ac67f2d

Please sign in to comment.