[Box Backup-commit] COMMIT r1340 - box/chris/general/lib/win32

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sat Mar 3 23:56:12 GMT 2007


Author: chris
Date: 2007-03-03 23:56:12 +0000 (Sat, 03 Mar 2007)
New Revision: 1340

Modified:
   box/chris/general/lib/win32/emu.cpp
Log:
Fix two memory leaks and one buffer overflow in codepage conversion code.


Modified: box/chris/general/lib/win32/emu.cpp
===================================================================
--- box/chris/general/lib/win32/emu.cpp	2007-03-03 22:34:12 UTC (rev 1339)
+++ box/chris/general/lib/win32/emu.cpp	2007-03-03 23:56:12 UTC (rev 1340)
@@ -976,7 +976,7 @@
 		return -1;
 	}
 
-	free(pBuffer);
+	delete [] pBuffer;
 	return 0;
 }
 
@@ -1619,7 +1619,7 @@
 	}
 
 	size_t WideSize = BufferSize / 5;
-	WCHAR* pWideBuffer = new WCHAR [WideSize];
+	WCHAR* pWideBuffer = new WCHAR [WideSize + 1];
 
 	if (!pWideBuffer)
 	{
@@ -1645,6 +1645,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