fixed some mismatched new and delete operators
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3465 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
d08b963619
commit
d07ec8774f
5 changed files with 35 additions and 17 deletions
|
@ -207,19 +207,30 @@ BYTE* CResourceEditor::GetResource(char* szType, char* szName, LANGID wLanguage)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CResourceEditor::FreeResource(BYTE* pbResource)
|
||||||
|
{
|
||||||
|
if (pbResource)
|
||||||
|
delete [] pbResource;
|
||||||
|
}
|
||||||
|
|
||||||
// Saves the edited PE into a buffer and returns it.
|
// Saves the edited PE into a buffer and returns it.
|
||||||
BYTE* CResourceEditor::Save(DWORD &dwSize) {
|
DWORD CResourceEditor::Save(BYTE* pbBuf, DWORD &dwSize) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
DWORD dwReqSize;
|
||||||
|
|
||||||
DWORD dwRsrcSize = m_cResDir->GetSize(); // Size of new resource section
|
DWORD dwRsrcSize = m_cResDir->GetSize(); // Size of new resource section
|
||||||
DWORD dwRsrcSizeAligned = RALIGN(dwRsrcSize, m_ntHeaders->OptionalHeader.FileAlignment); // Align it to FileAlignment
|
DWORD dwRsrcSizeAligned = RALIGN(dwRsrcSize, m_ntHeaders->OptionalHeader.FileAlignment); // Align it to FileAlignment
|
||||||
|
|
||||||
// Calculate the total new PE size
|
// Calculate the total new PE size
|
||||||
dwSize = m_iSize - IMAGE_FIRST_SECTION(m_ntHeaders)[m_dwResourceSectionIndex].SizeOfRawData + dwRsrcSizeAligned;
|
dwReqSize = m_iSize - IMAGE_FIRST_SECTION(m_ntHeaders)[m_dwResourceSectionIndex].SizeOfRawData + dwRsrcSizeAligned;
|
||||||
|
|
||||||
// Allocate memory for the new PE
|
if (!pbBuf || dwSize < dwReqSize)
|
||||||
BYTE* pbNewPE = new BYTE[dwSize];
|
return dwReqSize;
|
||||||
// Fill it with zeros
|
|
||||||
|
// Use buffer
|
||||||
|
BYTE* pbNewPE = pbBuf;
|
||||||
|
dwSize = dwReqSize;
|
||||||
|
// Fill buffer with zeros
|
||||||
ZeroMemory(pbNewPE, dwSize);
|
ZeroMemory(pbNewPE, dwSize);
|
||||||
|
|
||||||
BYTE* seeker = pbNewPE;
|
BYTE* seeker = pbNewPE;
|
||||||
|
@ -319,7 +330,7 @@ BYTE* CResourceEditor::Save(DWORD &dwSize) {
|
||||||
// m_dwResourceSectionIndex and m_dwResourceSectionVA have also been left unchanged as
|
// m_dwResourceSectionIndex and m_dwResourceSectionVA have also been left unchanged as
|
||||||
// we didn't move the resources section
|
// we didn't move the resources section
|
||||||
|
|
||||||
return pbNewPE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function scans exe sections and after find a match with given name
|
// This function scans exe sections and after find a match with given name
|
||||||
|
|
|
@ -60,9 +60,10 @@ public:
|
||||||
bool UpdateResource(char* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
bool UpdateResource(char* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||||
bool UpdateResource(WORD szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
bool UpdateResource(WORD szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||||
BYTE* GetResource(char* szType, char* szName, LANGID wLanguage);
|
BYTE* GetResource(char* szType, char* szName, LANGID wLanguage);
|
||||||
|
void FreeResource(BYTE* pbResource);
|
||||||
|
|
||||||
bool AddExtraVirtualSize2PESection(const char* pszSectionName, int addsize);
|
bool AddExtraVirtualSize2PESection(const char* pszSectionName, int addsize);
|
||||||
BYTE* Save(DWORD &dwSize);
|
DWORD Save(BYTE* pbBuf, DWORD &dwSize);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BYTE* m_pbPE;
|
BYTE* m_pbPE;
|
||||||
|
|
|
@ -1998,7 +1998,7 @@ again:
|
||||||
dlg = dt.Save(dwSize); \
|
dlg = dt.Save(dwSize); \
|
||||||
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(id), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, dwSize); \
|
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(id), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, dwSize); \
|
||||||
} \
|
} \
|
||||||
free(dlg); \
|
res_editor->FreeResource(dlg); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3177,17 +3177,23 @@ again:
|
||||||
|
|
||||||
void CEXEBuild::init_res_editor()
|
void CEXEBuild::init_res_editor()
|
||||||
{
|
{
|
||||||
build_compressor_set=true;
|
build_compressor_set = true;
|
||||||
if (!res_editor)
|
if (!res_editor)
|
||||||
res_editor=new CResourceEditor(header_data_new, exeheader_size_new);
|
res_editor = new CResourceEditor(header_data_new, exeheader_size_new);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEXEBuild::close_res_editor()
|
void CEXEBuild::close_res_editor()
|
||||||
{
|
{
|
||||||
if (!res_editor) return;
|
if (!res_editor) return;
|
||||||
unsigned char *header_data_new_edited = res_editor->Save((DWORD&)exeheader_size_new);
|
DWORD newsize;
|
||||||
|
// query size
|
||||||
|
newsize = res_editor->Save(NULL, newsize);
|
||||||
|
unsigned char *new_header = (unsigned char *) malloc(newsize);
|
||||||
|
// save
|
||||||
|
res_editor->Save(new_header, newsize);
|
||||||
free(header_data_new);
|
free(header_data_new);
|
||||||
header_data_new = header_data_new_edited;
|
header_data_new = new_header;
|
||||||
|
exeheader_size_new = (int) newsize;
|
||||||
delete res_editor;
|
delete res_editor;
|
||||||
res_editor=0;
|
res_editor=0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,7 +321,7 @@ int CEXEBuild::GenerateLangTables() {
|
||||||
DWORD dwSize; \
|
DWORD dwSize; \
|
||||||
dlg = td.Save(dwSize); \
|
dlg = td.Save(dwSize); \
|
||||||
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(id), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, dwSize); \
|
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(id), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, dwSize); \
|
||||||
free(dlg); \
|
res_editor->FreeResource(dlg); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ int CEXEBuild::GenerateLangTables() {
|
||||||
DWORD dwSize; \
|
DWORD dwSize; \
|
||||||
dlg = td.Save(dwSize); \
|
dlg = td.Save(dwSize); \
|
||||||
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(id+cur_offset), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, dwSize); \
|
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(id+cur_offset), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, dwSize); \
|
||||||
free(dlg); \
|
res_editor->FreeResource(dlg); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1907,7 +1907,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
DWORD dwSize;
|
DWORD dwSize;
|
||||||
dlg = dt.Save(dwSize);
|
dlg = dt.Save(dwSize);
|
||||||
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(IDD_INSTFILES), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, dwSize);
|
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(IDD_INSTFILES), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, dwSize);
|
||||||
free(dlg);
|
res_editor->FreeResource(dlg);
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
ERROR_MSG("Error setting smooth progress bar: %s\n", err.what());
|
ERROR_MSG("Error setting smooth progress bar: %s\n", err.what());
|
||||||
|
@ -2276,7 +2276,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
|
|
||||||
res_editor->UpdateResource(RT_DIALOG, IDD_INST, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, dwDlgSize);
|
res_editor->UpdateResource(RT_DIALOG, IDD_INST, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, dwDlgSize);
|
||||||
|
|
||||||
delete [] dlg;
|
res_editor->FreeResource(dlg);
|
||||||
|
|
||||||
dt.DlgUnitsToPixels(brandingCtl.sWidth, brandingCtl.sHeight);
|
dt.DlgUnitsToPixels(brandingCtl.sWidth, brandingCtl.sHeight);
|
||||||
SCRIPT_MSG("AddBrandingImage: %s %ux%u\n", line.gettoken_str(1), brandingCtl.sWidth, brandingCtl.sHeight);
|
SCRIPT_MSG("AddBrandingImage: %s %ux%u\n", line.gettoken_str(1), brandingCtl.sWidth, brandingCtl.sHeight);
|
||||||
|
@ -3020,7 +3020,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
DWORD dwSize;
|
DWORD dwSize;
|
||||||
dlg = td.Save(dwSize);
|
dlg = td.Save(dwSize);
|
||||||
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(IDD_INST), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, dwSize);
|
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(IDD_INST), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, dwSize);
|
||||||
free(dlg);
|
res_editor->FreeResource(dlg);
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
ERROR_MSG("Error while triming branding text control: %s\n", err.what());
|
ERROR_MSG("Error while triming branding text control: %s\n", err.what());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue