Skip to content

Commit

Permalink
Rewrote constructor to fix stack corruption.
Browse files Browse the repository at this point in the history
Copied code from NppTags.
  • Loading branch information
ffes committed Oct 23, 2014
1 parent 84a6125 commit 9c5d42b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ Version::Version(BYTE version[VERSION_DIGITS])

Version::Version(LPCWSTR version)
{
// Spilt the version in the seperate numbers
int numRead = swscanf(version, L"%d.%d.%d.%d", &_version[0], &_version[1], &_version[2], &_version[3]);
// Split the version in the seperate numbers
int v0, v1, v2, v3;
int numRead = swscanf(version, L"%d.%d.%d.%d", &v0, &v1, &v2, &v3);

// Set the items not read to 0
for (int i = numRead; i < VERSION_DIGITS; i++)
_version[i] = 0;
// Copy these numbers to the corresponding member of _version
_version[0] = (numRead > 0 ? v0 : 0);
_version[1] = (numRead > 1 ? v1 : 0);
_version[2] = (numRead > 2 ? v2 : 0);
_version[3] = (numRead > 3 ? v3 : 0);
}

///////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 9c5d42b

Please sign in to comment.