Skip to content

Commit

Permalink
Fix: possible memory corruption (#148)
Browse files Browse the repository at this point in the history
- fixed possible memory corruption inspired by reports from nzbget-ng
  • Loading branch information
dnzbk committed Jan 26, 2024
1 parent 8515370 commit 16ab25d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion daemon/util/NString.cpp
Expand Up @@ -155,7 +155,14 @@ void CString::AppendFmtV(const char* format, va_list ap)

int curLen = Length();
int newLen = curLen + addLen;
m_data = (char*)realloc(m_data, newLen + 1);

char* newData = (char*)realloc(m_data, newLen + 1);
if (newData == nullptr)
{
return;
}

m_data = newData;

vsnprintf(m_data + curLen, newLen + 1, format, ap2);

Expand Down
2 changes: 1 addition & 1 deletion lib/par2/reedsolomon.h
Expand Up @@ -122,7 +122,7 @@ inline ReedSolomon<g>::ReedSolomon(std::ostream& cout, std::ostream& cerr) :
datamissingindex = 0;
database = 0;

outputrows.empty();
outputrows.clear();

outputcount = 0;

Expand Down

0 comments on commit 16ab25d

Please sign in to comment.