Fix GCC array bounds warning when accessing g_usrvars

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6258 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2012-09-06 22:43:31 +00:00
parent 667a2c8cae
commit c6fdb4436d
5 changed files with 18 additions and 8 deletions

View file

@ -514,14 +514,14 @@ DWORD CResourceEditor::Save(BYTE* pbBuf, DWORD &dwSize) {
// This function scans exe sections and after find a match with given name
// increments it's virtual size (auto fixes image size based on section alignment, etc)
// Jim Park: The section name must be ASCII code. Do not TCHAR this stuff.
bool CResourceEditor::AddExtraVirtualSize2PESection(const char* pszSectionName, int addsize)
bool CResourceEditor::SetPESectionVirtualSize(const char* pszSectionName, DWORD newsize)
{
PIMAGE_SECTION_HEADER sectionHeadersArray = IMAGE_FIRST_SECTION(m_ntHeaders);
// Refresh the headers of the sections that come after the resource section, and the data directory
for (int i = 0; i < ConvertEndianness(m_ntHeaders->FileHeader.NumberOfSections); i++) {
if (!strcmp((LPCSTR)sectionHeadersArray[i].Name, pszSectionName)) {
sectionHeadersArray[i].Misc.VirtualSize = AlignVA(AdjustVA(sectionHeadersArray[i].Misc.VirtualSize, addsize));
sectionHeadersArray[i].Misc.VirtualSize = AlignVA(ConvertEndianness(newsize));
sectionHeadersArray[i].Characteristics &= ConvertEndianness((DWORD) ~IMAGE_SCN_MEM_DISCARDABLE);