From e58680c99610b5d8330f9c88230e02d868c1346c Mon Sep 17 00:00:00 2001 From: anders_k Date: Sun, 6 Sep 2015 20:15:56 +0000 Subject: [PATCH] CResourceDirectoryEntry::GetName() does not need to duplicate the string git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6603 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/ExDLL/exdll.c | 2 +- Source/ResourceEditor.cpp | 14 +++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Contrib/ExDLL/exdll.c b/Contrib/ExDLL/exdll.c index 5fa6dcf1..e4e807e7 100644 --- a/Contrib/ExDLL/exdll.c +++ b/Contrib/ExDLL/exdll.c @@ -24,7 +24,7 @@ void __declspec(dllexport) myFunction(HWND hwndParent, int string_size, // do your stuff here { - LPTSTR msgbuf = GlobalAlloc(GPTR, (3 + string_size + 1) * sizeof(*msgbuf)); + LPTSTR msgbuf = (LPTSTR) GlobalAlloc(GPTR, (3 + string_size + 1) * sizeof(*msgbuf)); if (msgbuf) { wsprintf(msgbuf, TEXT("$0=%s"), getuservariable(INST_0)); diff --git a/Source/ResourceEditor.cpp b/Source/ResourceEditor.cpp index eb143d79..6019b031 100644 --- a/Source/ResourceEditor.cpp +++ b/Source/ResourceEditor.cpp @@ -719,8 +719,6 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) { seeker += RALIGN(iLen * sizeof(WINWCHAR) + sizeof(WORD), 4); - free(szName); - qStrings.pop(); } @@ -823,15 +821,11 @@ bool CResourceDirectory::AddEntry(CResourceDirectoryEntry* entry) { for (i = 0; i < m_rdDir.NumberOfNamedEntries; i++) { WINWCHAR* szName = m_vEntries[i]->GetName(); int cmp = WinWStrCmp(szName, szEntName); - free(szName); - if (cmp == 0) { - free(szEntName); + if (cmp == 0) return false; - } if (cmp > 0) break; } - free(szEntName); m_rdDir.NumberOfNamedEntries++; } else { @@ -874,8 +868,6 @@ int CResourceDirectory::Find(const WINWCHAR* szName) { WINWCHAR* szEntName = m_vEntries[i]->GetName(); int cmp = WinWStrCmp(szName, szEntName); - free(szEntName); - if (!cmp) return i; } @@ -963,7 +955,7 @@ CResourceDirectoryEntry::CResourceDirectoryEntry(const WINWCHAR* szName, CResour } CResourceDirectoryEntry::~CResourceDirectoryEntry() { - if (m_szName && m_bHasName) + if (m_bHasName) free(m_szName); } @@ -977,7 +969,7 @@ bool CResourceDirectoryEntry::HasName() { // Don't forget to free the memory used by the string after usage! WINWCHAR* CResourceDirectoryEntry::GetName() { - return m_bHasName ? WinWStrDupFromWinWStr(m_szName) : 0; + return m_bHasName ? m_szName : 0; } int CResourceDirectoryEntry::GetNameLength() {