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); len = strlen(str);
ret = HeapAlloc(GetProcessHeap(), 0, len + 1); ret = HeapAlloc(GetProcessHeap(), 0, len + 1);
memcpy(ret, str, len + 1); if (ret != NULL)
memcpy(ret, str, len + 1);
return ret; return ret;
} }

View file

@ -656,7 +656,7 @@ static LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
LPSTR textA = (LPSTR)lParam; LPSTR textA = (LPSTR)lParam;
INT countW = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0); INT countW = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
if((textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) 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); 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; LPWSTR nameW = NULL;
if(nameA) if(nameA)
{ {
INT countW = MultiByteToWideChar(CP_ACP, 0, nameA, -1, NULL, 0); INT countW = MultiByteToWideChar(CP_ACP, 0, nameA, -1, NULL, 0);
if((nameW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) if((nameW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR))))
MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, countW); MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, countW);
} }
result = EDIT_WM_Create(es, nameW); result = EDIT_WM_Create(es, nameW);
HeapFree(GetProcessHeap(), 0, 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 /* The buffer has been expanded, create a new line and
insert it into the link list */ insert it into the link list */
LINEDEF *new_line = HeapAlloc(GetProcessHeap(), 0, sizeof(LINEDEF)); LINEDEF *new_line = HeapAlloc(GetProcessHeap(), 0, sizeof(LINEDEF));
if (new_line == NULL)
break;
new_line->next = previous_line->next; new_line->next = previous_line->next;
previous_line->next = new_line; previous_line->next = new_line;
current_line = 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); countA = WideCharToMultiByte(CP_ACP, 0, es->text + start, count, NULL, 0, NULL, NULL);
textA = HeapAlloc(GetProcessHeap(), 0, countA); textA = HeapAlloc(GetProcessHeap(), 0, countA);
if (textA == NULL)
return 0;
WideCharToMultiByte(CP_ACP, 0, es->text + start, count, textA, countA, NULL, NULL); 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", 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); 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) { if (es->style & ES_PASSWORD) {
INT len = get_text_length(es); INT len = get_text_length(es);
LPWSTR text = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); LPWSTR text = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
if (text == NULL)
return NULL;
text[len] = '\0'; text[len] = '\0';
while(len) text[--len] = es->password_char; while(len) text[--len] = es->password_char;
return text; return text;
@ -3958,6 +3964,11 @@ static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, LPINT tabs)
es->tabs = NULL; es->tabs = NULL;
else { else {
es->tabs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT)); 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)); memcpy(es->tabs, tabs, count * sizeof(INT));
} }
return TRUE; return TRUE;
@ -4051,6 +4062,8 @@ static BOOL EDIT_EM_Undo(EDITSTATE *es)
ulength = strlenW(es->undo_text); ulength = strlenW(es->undo_text);
utext = HeapAlloc(GetProcessHeap(), 0, (ulength + 1) * sizeof(WCHAR)); utext = HeapAlloc(GetProcessHeap(), 0, (ulength + 1) * sizeof(WCHAR));
if (utext == NULL)
return FALSE;
strcpyW(utext, es->undo_text); 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 */ /* We need to grow the array */
max_items += LB_ARRAY_GRANULARITY; max_items += LB_ARRAY_GRANULARITY;
if (descr->items) if (descr->items)
{
item = HeapReAlloc( GetProcessHeap(), 0, descr->items, item = HeapReAlloc( GetProcessHeap(), 0, descr->items,
max_items * sizeof(LB_ITEMDATA) ); max_items * sizeof(LB_ITEMDATA) );
if (!item)
{
SEND_NOTIFICATION( descr, LBN_ERRSPACE );
return LB_ERRSPACE;
}
}
else else
item = HeapAlloc( GetProcessHeap(), 0, item = HeapAlloc( GetProcessHeap(), 0,
max_items * sizeof(LB_ITEMDATA) ); max_items * sizeof(LB_ITEMDATA) );

View file

@ -630,6 +630,8 @@ UINT WINAPI PrivateExtractIconsA (
UINT ret; UINT ret;
INT len = MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, NULL, 0); INT len = MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, NULL, 0);
LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (lpwstrFile == NULL)
return 0;
MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, lpwstrFile, len); MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, lpwstrFile, len);
ret = PrivateExtractIconsW(lpwstrFile, nIndex, sizeX, sizeY, phicon, piconid, nIcons, flags); ret = PrivateExtractIconsW(lpwstrFile, nIndex, sizeX, sizeY, phicon, piconid, nIcons, flags);
@ -709,6 +711,8 @@ UINT WINAPI PrivateExtractIconExA (
UINT ret; UINT ret;
INT len = MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, NULL, 0); INT len = MultiByteToWideChar(CP_ACP, 0, lpstrFile, -1, NULL, 0);
LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); 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); 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) if (Allocate)
{ {
*MBString = RtlAllocateHeap(GetProcessHeap(), 0, MBSize); LPSTR SafeString = RtlAllocateHeap(GetProcessHeap(), 0, MBSize);
if (SafeString == NULL)
return 0;
*MBString = SafeString;
} }
if (CodePage == 0) if (CodePage == 0)
{ {
@ -585,7 +588,10 @@ DWORD STDCALL MBToWCSEx(WORD CodePage,LPSTR MBString,LONG MBSize,LPWSTR *Unicode
} }
if (Allocate) if (Allocate)
{ {
*UnicodeString = RtlAllocateHeap(GetProcessHeap(), 0, UnicodeSize); LPWSTR SafeString = RtlAllocateHeap(GetProcessHeap(), 0, UnicodeSize);
if (SafeString == NULL)
return 0;
*UnicodeString = SafeString;
} }
UnicodeSize *= sizeof(WCHAR); UnicodeSize *= sizeof(WCHAR);
if (CodePage == 0) 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? */ if (GET_WORD(p) == 0xffff) /* Is it an integer id? */
{ {
info->windowName = HeapAlloc( GetProcessHeap(), 0, sizeof(L"#65535") ); info->windowName = HeapAlloc( GetProcessHeap(), 0, sizeof(L"#65535") );
swprintf((LPWSTR)info->windowName, L"#%d", GET_WORD(p + 1)); if (info->windowName != NULL)
info->windowNameFree = TRUE; {
swprintf((LPWSTR)info->windowName, L"#%d", GET_WORD(p + 1));
info->windowNameFree = TRUE;
}
else
{
info->windowNameFree = FALSE;
}
p += 2; p += 2;
} }
else else
@ -280,7 +287,7 @@ static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template, const DLG_TEMPL
HWND hwndCtrl, hwndDefButton = 0; HWND hwndCtrl, hwndDefButton = 0;
INT items = dlgTemplate->nbItems; INT items = dlgTemplate->nbItems;
if (!(dlgInfo = GETDLGINFO(hwnd))) return -1; if (!(dlgInfo = GETDLGINFO(hwnd))) return FALSE;
while (items--) 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 ); DWORD len = WideCharToMultiByte( CP_ACP, 0, info.className, -1, NULL, 0, NULL, NULL );
class = HeapAlloc( GetProcessHeap(), 0, len ); 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)) if (HIWORD(caption))
{ {
DWORD len = WideCharToMultiByte( CP_ACP, 0, info.windowName, -1, NULL, 0, NULL, NULL ); DWORD len = WideCharToMultiByte( CP_ACP, 0, info.windowName, -1, NULL, 0, NULL, NULL );
caption = HeapAlloc( GetProcessHeap(), 0, len ); 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, if (class != NULL && caption != NULL)
MulDiv(info.x, dlgInfo->xBaseUnit, 4), {
MulDiv(info.y, dlgInfo->yBaseUnit, 8), hwndCtrl = CreateWindowExA( info.exStyle | WS_EX_NOPARENTNOTIFY,
MulDiv(info.cx, dlgInfo->xBaseUnit, 4), class, caption, info.style | WS_CHILD,
MulDiv(info.cy, dlgInfo->yBaseUnit, 8), MulDiv(info.x, dlgInfo->xBaseUnit, 4),
hwnd, (HMENU)info.id, MulDiv(info.y, dlgInfo->yBaseUnit, 8),
hInst, (LPVOID)info.data ); 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(class)) HeapFree( GetProcessHeap(), 0, class );
if (HIWORD(caption)) HeapFree( GetProcessHeap(), 0, caption ); 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 ); DWORD len = WideCharToMultiByte( CP_ACP, 0, template.className, -1, NULL, 0, NULL, NULL );
class = HeapAlloc( GetProcessHeap(), 0, len ); 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)) if (HIWORD(caption))
{ {
DWORD len = WideCharToMultiByte( CP_ACP, 0, template.caption, -1, NULL, 0, NULL, NULL ); DWORD len = WideCharToMultiByte( CP_ACP, 0, template.caption, -1, NULL, 0, NULL, NULL );
caption = HeapAlloc( GetProcessHeap(), 0, len ); 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, if (class != NULL && caption != NULL)
rect.left, rect.top, rect.right, rect.bottom, {
owner, hMenu, hInst, NULL, hwnd = User32CreateWindowEx(template.exStyle, class, caption,
FALSE); 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(class)) HeapFree( GetProcessHeap(), 0, class );
if (HIWORD(caption)) HeapFree( GetProcessHeap(), 0, caption ); 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 ); INT ret, len = MultiByteToWideChar( CP_ACP, 0, spec, -1, NULL, 0 );
LPWSTR specW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); LPWSTR specW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
if (specW == NULL)
return FALSE;
MultiByteToWideChar( CP_ACP, 0, spec, -1, specW, len ); MultiByteToWideChar( CP_ACP, 0, spec, -1, specW, len );
ret = DIALOG_DlgDirListW( hDlg, specW, idLBox, idStatic, attrib, combo ); ret = DIALOG_DlgDirListW( hDlg, specW, idLBox, idStatic, attrib, combo );
WideCharToMultiByte( CP_ACP, 0, specW, -1, spec, 0x7fffffff, NULL, NULL ); 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) if (ci->child[i] == child)
{ {
HWND *new_child = HeapAlloc(GetProcessHeap(), 0, (ci->nActiveChildren - 1) * sizeof(HWND)); HWND *new_child = HeapAlloc(GetProcessHeap(), 0, (ci->nActiveChildren - 1) * sizeof(HWND));
memcpy(new_child, ci->child, i * sizeof(HWND)); if (new_child != NULL)
if (i + 1 < ci->nActiveChildren) {
memcpy(new_child + i, ci->child + i + 1, (ci->nActiveChildren - i - 1) * sizeof(HWND)); memcpy(new_child, ci->child, i * sizeof(HWND));
HeapFree(GetProcessHeap(), 0, ci->child); if (i + 1 < ci->nActiveChildren)
ci->child = new_child; 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--; ci->nActiveChildren--;
break; break;
@ -1248,15 +1259,17 @@ static LRESULT MDIClientWndProc_common( HWND hwnd, UINT message,
case WM_CREATE: case WM_CREATE:
if (GetWindowLongW((HWND)lParam, GWL_EXSTYLE) & WS_EX_MDICHILD) if (GetWindowLongW((HWND)lParam, GWL_EXSTYLE) & WS_EX_MDICHILD)
{ {
ci->nTotalCreated++;
ci->nActiveChildren++;
if (!ci->child) if (!ci->child)
ci->child = HeapAlloc(GetProcessHeap(), 0, sizeof(HWND)); ci->child = HeapAlloc(GetProcessHeap(), 0, sizeof(HWND));
else 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; break;
@ -1343,6 +1356,8 @@ LRESULT WINAPI DefFrameProcA( HWND hwnd, HWND hwndMDIClient,
{ {
DWORD len = MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0 ); DWORD len = MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0 );
LPWSTR text = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); LPWSTR text = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
if (text == NULL)
return 0;
MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, text, len ); MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, text, len );
MDI_UpdateFrameText( hwnd, hwndMDIClient, text ); MDI_UpdateFrameText( hwnd, hwndMDIClient, text );
HeapFree( GetProcessHeap(), 0, text ); HeapFree( GetProcessHeap(), 0, text );