Hopefully fixes bug #1110. Requested fixed by amine48rz.

See issue #1110 for more details.

svn path=/trunk/; revision=33503
This commit is contained in:
Gregor Brunmar 2008-05-13 20:14:30 +00:00
parent 286385fc87
commit c5465c5668
7 changed files with 108 additions and 37 deletions

View file

@ -1847,7 +1847,8 @@ static char *strdupA(LPCSTR str)
len = strlen(str);
ret = HeapAlloc(GetProcessHeap(), 0, len + 1);
memcpy(ret, str, len + 1);
if (ret != NULL)
memcpy(ret, str, len + 1);
return ret;
}

View file

@ -656,7 +656,7 @@ static LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
LPSTR textA = (LPSTR)lParam;
INT countW = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
if((textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR))))
MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW);
MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW);
}
EDIT_EM_ReplaceSel(es, (BOOL)wParam, textW, TRUE, TRUE);
@ -930,9 +930,9 @@ static LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
LPWSTR nameW = NULL;
if(nameA)
{
INT countW = MultiByteToWideChar(CP_ACP, 0, nameA, -1, NULL, 0);
if((nameW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR))))
MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, countW);
INT countW = MultiByteToWideChar(CP_ACP, 0, nameA, -1, NULL, 0);
if((nameW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR))))
MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, countW);
}
result = EDIT_WM_Create(es, nameW);
HeapFree(GetProcessHeap(), 0, nameW);
@ -1222,6 +1222,8 @@ static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta
/* The buffer has been expanded, create a new line and
insert it into the link list */
LINEDEF *new_line = HeapAlloc(GetProcessHeap(), 0, sizeof(LINEDEF));
if (new_line == NULL)
break;
new_line->next = previous_line->next;
previous_line->next = new_line;
current_line = new_line;
@ -1517,6 +1519,8 @@ static INT EDIT_CallWordBreakProc(EDITSTATE *es, INT start, INT index, INT count
countA = WideCharToMultiByte(CP_ACP, 0, es->text + start, count, NULL, 0, NULL, NULL);
textA = HeapAlloc(GetProcessHeap(), 0, countA);
if (textA == NULL)
return 0;
WideCharToMultiByte(CP_ACP, 0, es->text + start, count, textA, countA, NULL, NULL);
TRACE_(relay)("(ANSI wordbrk=%p,str=%s,idx=%d,cnt=%d,act=%d)\n",
es->word_break_proc, debugstr_an(textA, countA), index, countA, action);
@ -1723,6 +1727,8 @@ static LPWSTR EDIT_GetPasswordPointer_SL(EDITSTATE *es)
if (es->style & ES_PASSWORD) {
INT len = get_text_length(es);
LPWSTR text = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
if (text == NULL)
return NULL;
text[len] = '\0';
while(len) text[--len] = es->password_char;
return text;
@ -3958,6 +3964,11 @@ static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, LPINT tabs)
es->tabs = NULL;
else {
es->tabs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT));
if (es->tabs == NULL)
{
es->tabs_count = 0;
return FALSE;
}
memcpy(es->tabs, tabs, count * sizeof(INT));
}
return TRUE;
@ -4051,6 +4062,8 @@ static BOOL EDIT_EM_Undo(EDITSTATE *es)
ulength = strlenW(es->undo_text);
utext = HeapAlloc(GetProcessHeap(), 0, (ulength + 1) * sizeof(WCHAR));
if (utext == NULL)
return FALSE;
strcpyW(utext, es->undo_text);

View file

@ -1620,8 +1620,15 @@ static LRESULT LISTBOX_InsertItem( LB_DESCR *descr, INT index,
/* We need to grow the array */
max_items += LB_ARRAY_GRANULARITY;
if (descr->items)
{
item = HeapReAlloc( GetProcessHeap(), 0, descr->items,
max_items * sizeof(LB_ITEMDATA) );
if (!item)
{
SEND_NOTIFICATION( descr, LBN_ERRSPACE );
return LB_ERRSPACE;
}
}
else
item = HeapAlloc( GetProcessHeap(), 0,
max_items * sizeof(LB_ITEMDATA) );

View file

@ -630,6 +630,8 @@ UINT WINAPI PrivateExtractIconsA (
UINT ret;
INT len = MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, NULL, 0);
LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (lpwstrFile == NULL)
return 0;
MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, lpwstrFile, len);
ret = PrivateExtractIconsW(lpwstrFile, nIndex, sizeX, sizeY, phicon, piconid, nIcons, flags);
@ -709,6 +711,8 @@ UINT WINAPI PrivateExtractIconExA (
UINT ret;
INT len = MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, NULL, 0);
LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (lpwstrFile == NULL)
return 0;
TRACE("%s %d %p %p %d\n", lpstrFile, nIndex, phIconLarge, phIconSmall, nIcons);

View file

@ -553,7 +553,10 @@ DWORD STDCALL WCSToMBEx(WORD CodePage,LPWSTR UnicodeString,LONG UnicodeSize,LPST
}
if (Allocate)
{
*MBString = RtlAllocateHeap(GetProcessHeap(), 0, MBSize);
LPSTR SafeString = RtlAllocateHeap(GetProcessHeap(), 0, MBSize);
if (SafeString == NULL)
return 0;
*MBString = SafeString;
}
if (CodePage == 0)
{
@ -585,7 +588,10 @@ DWORD STDCALL MBToWCSEx(WORD CodePage,LPSTR MBString,LONG MBSize,LPWSTR *Unicode
}
if (Allocate)
{
*UnicodeString = RtlAllocateHeap(GetProcessHeap(), 0, UnicodeSize);
LPWSTR SafeString = RtlAllocateHeap(GetProcessHeap(), 0, UnicodeSize);
if (SafeString == NULL)
return 0;
*UnicodeString = SafeString;
}
UnicodeSize *= sizeof(WCHAR);
if (CodePage == 0)

View file

@ -244,8 +244,15 @@ static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info,
if (GET_WORD(p) == 0xffff) /* Is it an integer id? */
{
info->windowName = HeapAlloc( GetProcessHeap(), 0, sizeof(L"#65535") );
swprintf((LPWSTR)info->windowName, L"#%d", GET_WORD(p + 1));
info->windowNameFree = TRUE;
if (info->windowName != NULL)
{
swprintf((LPWSTR)info->windowName, L"#%d", GET_WORD(p + 1));
info->windowNameFree = TRUE;
}
else
{
info->windowNameFree = FALSE;
}
p += 2;
}
else
@ -280,7 +287,7 @@ static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template, const DLG_TEMPL
HWND hwndCtrl, hwndDefButton = 0;
INT items = dlgTemplate->nbItems;
if (!(dlgInfo = GETDLGINFO(hwnd))) return -1;
if (!(dlgInfo = GETDLGINFO(hwnd))) return FALSE;
while (items--)
{
@ -313,22 +320,30 @@ static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template, const DLG_TEMPL
{
DWORD len = WideCharToMultiByte( CP_ACP, 0, info.className, -1, NULL, 0, NULL, NULL );
class = HeapAlloc( GetProcessHeap(), 0, len );
WideCharToMultiByte( CP_ACP, 0, info.className, -1, class, len, NULL, NULL );
if (class != NULL)
WideCharToMultiByte( CP_ACP, 0, info.className, -1, class, len, NULL, NULL );
}
if (HIWORD(caption))
{
DWORD len = WideCharToMultiByte( CP_ACP, 0, info.windowName, -1, NULL, 0, NULL, NULL );
caption = HeapAlloc( GetProcessHeap(), 0, len );
WideCharToMultiByte( CP_ACP, 0, info.windowName, -1, caption, len, NULL, NULL );
if (caption != NULL)
WideCharToMultiByte( CP_ACP, 0, info.windowName, -1, caption, len, NULL, NULL );
}
hwndCtrl = CreateWindowExA( info.exStyle | WS_EX_NOPARENTNOTIFY,
class, caption, info.style | WS_CHILD,
MulDiv(info.x, dlgInfo->xBaseUnit, 4),
MulDiv(info.y, dlgInfo->yBaseUnit, 8),
MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
hwnd, (HMENU)info.id,
hInst, (LPVOID)info.data );
if (class != NULL && caption != NULL)
{
hwndCtrl = CreateWindowExA( info.exStyle | WS_EX_NOPARENTNOTIFY,
class, caption, info.style | WS_CHILD,
MulDiv(info.x, dlgInfo->xBaseUnit, 4),
MulDiv(info.y, dlgInfo->yBaseUnit, 8),
MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
hwnd, (HMENU)info.id,
hInst, (LPVOID)info.data );
}
else
hwndCtrl = NULL;
if (HIWORD(class)) HeapFree( GetProcessHeap(), 0, class );
if (HIWORD(caption)) HeapFree( GetProcessHeap(), 0, caption );
}
@ -750,19 +765,27 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
{
DWORD len = WideCharToMultiByte( CP_ACP, 0, template.className, -1, NULL, 0, NULL, NULL );
class = HeapAlloc( GetProcessHeap(), 0, len );
WideCharToMultiByte( CP_ACP, 0, template.className, -1, class, len, NULL, NULL );
if (class != NULL)
WideCharToMultiByte( CP_ACP, 0, template.className, -1, class, len, NULL, NULL );
}
if (HIWORD(caption))
{
DWORD len = WideCharToMultiByte( CP_ACP, 0, template.caption, -1, NULL, 0, NULL, NULL );
caption = HeapAlloc( GetProcessHeap(), 0, len );
WideCharToMultiByte( CP_ACP, 0, template.caption, -1, caption, len, NULL, NULL );
if (caption != NULL)
WideCharToMultiByte( CP_ACP, 0, template.caption, -1, caption, len, NULL, NULL );
}
hwnd = User32CreateWindowEx(template.exStyle, class, caption,
template.style & ~WS_VISIBLE,
rect.left, rect.top, rect.right, rect.bottom,
owner, hMenu, hInst, NULL,
FALSE);
if (class != NULL && caption != NULL)
{
hwnd = User32CreateWindowEx(template.exStyle, class, caption,
template.style & ~WS_VISIBLE,
rect.left, rect.top, rect.right, rect.bottom,
owner, hMenu, hInst, NULL,
FALSE);
}
else
hwnd = NULL;
if (HIWORD(class)) HeapFree( GetProcessHeap(), 0, class );
if (HIWORD(caption)) HeapFree( GetProcessHeap(), 0, caption );
}
@ -1272,6 +1295,8 @@ static INT DIALOG_DlgDirListA( HWND hDlg, LPSTR spec, INT idLBox,
{
INT ret, len = MultiByteToWideChar( CP_ACP, 0, spec, -1, NULL, 0 );
LPWSTR specW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
if (specW == NULL)
return FALSE;
MultiByteToWideChar( CP_ACP, 0, spec, -1, specW, len );
ret = DIALOG_DlgDirListW( hDlg, specW, idLBox, idStatic, attrib, combo );
WideCharToMultiByte( CP_ACP, 0, specW, -1, spec, 0x7fffffff, NULL, NULL );

View file

@ -592,11 +592,22 @@ static LRESULT MDIDestroyChild( HWND client, MDICLIENTINFO *ci,
if (ci->child[i] == child)
{
HWND *new_child = HeapAlloc(GetProcessHeap(), 0, (ci->nActiveChildren - 1) * sizeof(HWND));
memcpy(new_child, ci->child, i * sizeof(HWND));
if (i + 1 < ci->nActiveChildren)
memcpy(new_child + i, ci->child + i + 1, (ci->nActiveChildren - i - 1) * sizeof(HWND));
HeapFree(GetProcessHeap(), 0, ci->child);
ci->child = new_child;
if (new_child != NULL)
{
memcpy(new_child, ci->child, i * sizeof(HWND));
if (i + 1 < ci->nActiveChildren)
memcpy(new_child + i, ci->child + i + 1, (ci->nActiveChildren - i - 1) * sizeof(HWND));
HeapFree(GetProcessHeap(), 0, ci->child);
ci->child = new_child;
}
else
{
UINT c;
for (c = i; c < ci->nActiveChildren - 1; c++)
{
ci->child[c] = ci->child[c+1];
}
}
ci->nActiveChildren--;
break;
@ -1248,15 +1259,17 @@ static LRESULT MDIClientWndProc_common( HWND hwnd, UINT message,
case WM_CREATE:
if (GetWindowLongW((HWND)lParam, GWL_EXSTYLE) & WS_EX_MDICHILD)
{
ci->nTotalCreated++;
ci->nActiveChildren++;
if (!ci->child)
ci->child = HeapAlloc(GetProcessHeap(), 0, sizeof(HWND));
else
ci->child = HeapReAlloc(GetProcessHeap(), 0, ci->child, sizeof(HWND) * ci->nActiveChildren);
ci->child = HeapReAlloc(GetProcessHeap(), 0, ci->child, sizeof(HWND) * (ci->nActiveChildren + 1));
ci->child[ci->nActiveChildren - 1] = (HWND)lParam;
if (ci->child != NULL)
{
ci->child[ci->nActiveChildren] = (HWND)lParam;
ci->nTotalCreated++;
ci->nActiveChildren++;
}
}
break;
@ -1343,6 +1356,8 @@ LRESULT WINAPI DefFrameProcA( HWND hwnd, HWND hwndMDIClient,
{
DWORD len = MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0 );
LPWSTR text = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
if (text == NULL)
return 0;
MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, text, len );
MDI_UpdateFrameText( hwnd, hwndMDIClient, text );
HeapFree( GetProcessHeap(), 0, text );