summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tlillqvist@novell.com>2011-01-13 23:49:18 +0200
committerTor Lillqvist <tml@hemulen.(none)>2011-01-14 12:57:58 +0200
commita8aa27383ae8570b8cd73376b54f114bd74afac6 (patch)
tree3225e23f53733e7b7a34d3483f55602fffc2adc0
parentd7b0664fa0966efc77dc2f6a93d3e68adbff00aa (diff)
Fix buffer size problem that broke MSI installer localization
(cherry picked from commit 5b7719a49fd57a9f446201fabc02bf1787dbbeee) Signed-off-by: Thorsten Behrens <thb@documentfoundation.org> Signed-off-by: Fridrich Strba <fridrich.strba@bluewin.ch> Signed-off-by: Michael Meeks <michael.meeks@novell.com>
-rw-r--r--desktop/win32/source/setup/setup.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/desktop/win32/source/setup/setup.cpp b/desktop/win32/source/setup/setup.cpp
index 8bebaa22de..17466960b6 100644
--- a/desktop/win32/source/setup/setup.cpp
+++ b/desktop/win32/source/setup/setup.cpp
@@ -265,22 +265,21 @@ boolean SetupAppX::GetProfileSection( LPCTSTR pFileName, LPCTSTR pSection,
{
if ( !rSize || !*pRetBuf )
{
- rSize = 512;
+ rSize = 10000;
*pRetBuf = new TCHAR[ rSize ];
}
DWORD nRet = GetPrivateProfileSection( pSection, *pRetBuf, rSize, pFileName );
- if ( nRet && ( nRet + 2 > rSize ) ) // buffer was too small, retry with bigger one
+ while ( nRet && ( nRet + 2 == rSize ) ) // buffer was too small, retry until big enough
{
- if ( nRet < 32767 - 2 )
- {
- delete [] (*pRetBuf);
- rSize = nRet + 2;
- *pRetBuf = new TCHAR[ rSize ];
+ if (rSize > 1000000)
+ break;
+ delete [] (*pRetBuf);
+ rSize = rSize * 2;
+ *pRetBuf = new TCHAR[ rSize ];
- nRet = GetPrivateProfileSection( pSection, *pRetBuf, rSize, pFileName );
- }
+ nRet = GetPrivateProfileSection( pSection, *pRetBuf, rSize, pFileName );
}
if ( !nRet )
@@ -292,7 +291,7 @@ boolean SetupAppX::GetProfileSection( LPCTSTR pFileName, LPCTSTR pSection,
Log( sBuf );
return false;
}
- else if ( nRet + 2 > rSize )
+ else if ( nRet + 2 == rSize )
{
SetError( ERROR_OUTOFMEMORY );
Log( TEXT( "ERROR: GetPrivateProfileSection() out of memory\r\n" ) );