[Box Backup-commit] COMMIT r1405 - box/chris/merge/lib/win32

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sat Mar 10 17:38:48 GMT 2007


Author: chris
Date: 2007-03-10 17:38:48 +0000 (Sat, 10 Mar 2007)
New Revision: 1405

Modified:
   box/chris/merge/lib/win32/emu.cpp
Log:
Fix two memory leaks and one buffer overflow in codepage conversion code.
(refs #3, merges [1340])


Modified: box/chris/merge/lib/win32/emu.cpp
===================================================================
--- box/chris/merge/lib/win32/emu.cpp	2007-03-10 17:37:30 UTC (rev 1404)
+++ box/chris/merge/lib/win32/emu.cpp	2007-03-10 17:38:48 UTC (rev 1405)
@@ -978,7 +978,7 @@
 		return -1;
 	}
 
-	free(pBuffer);
+	delete [] pBuffer;
 	return 0;
 }
 
@@ -1621,7 +1621,7 @@
 	}
 
 	size_t WideSize = BufferSize / 5;
-	WCHAR* pWideBuffer = new WCHAR [WideSize];
+	WCHAR* pWideBuffer = new WCHAR [WideSize + 1];
 
 	if (!pWideBuffer)
 	{
@@ -1647,6 +1647,8 @@
 	pWideBuffer[numCharsRead] = 0;
 
 	char* pUtf8 = ConvertFromWideString(pWideBuffer, GetConsoleCP());
+	delete [] pWideBuffer;
+
 	strncpy(pBuffer, pUtf8, BufferSize);
 	delete [] pUtf8;
 




More information about the Boxbackup-commit mailing list