Skip to content

Commit

Permalink
minor code simplification after overflow bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-chambers committed Aug 2, 2023
1 parent 9db5504 commit 6ddacdb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions daemon/util/NString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ void CString::AppendFmtV(const char* format, va_list ap)
if (addLen < 0) return; // error

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

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

va_end(ap2);
}
Expand Down

0 comments on commit 6ddacdb

Please sign in to comment.