small bugfix

This commit is contained in:
NtQuery 2014-03-13 21:27:18 +01:00
parent f2123991bd
commit 12ae6dcb9d
1 changed files with 138 additions and 132 deletions

View File

@ -138,17 +138,21 @@ INT_PTR CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (cnt != 0 && cnt != LB_ERR)
{
WCHAR * copy = 0;
int copyLength = 0;
WCHAR * copy = (WCHAR *)calloc(1, sizeof(WCHAR));
int copyLength = 1;
for(LRESULT i=0; i<cnt; i++) {
LRESULT stringLength = SendMessageW(hLogBox, LB_GETTEXTLEN, i, 0);
copyLength += stringLength + 1 + 2;
copyLength += stringLength + 2;
copy = (WCHAR *)realloc(copy, copyLength * sizeof(WCHAR));
if (copy)
{
copy[copyLength - stringLength - 1 - 2] = 0;
copy[copyLength - stringLength - 2] = 0;
}
else
{
return FALSE;
}
WCHAR * buf = (WCHAR *)calloc(stringLength + 1, sizeof(WCHAR));
@ -183,6 +187,8 @@ INT_PTR CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
CloseClipboard();
free(copy);
}
@ -201,7 +207,7 @@ INT_PTR CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
default:
{
return false;
return FALSE;
}
}
return 0;