summaryrefslogtreecommitdiff
path: root/src/modules/addcontact/addcontact.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/addcontact/addcontact.cpp')
-rw-r--r--src/modules/addcontact/addcontact.cpp45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/modules/addcontact/addcontact.cpp b/src/modules/addcontact/addcontact.cpp
index 5742a90402..3a98550715 100644
--- a/src/modules/addcontact/addcontact.cpp
+++ b/src/modules/addcontact/addcontact.cpp
@@ -237,30 +237,29 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp
INT_PTR AddContactDialog(WPARAM wParam, LPARAM lParam)
{
- if (lParam) {
- ADDCONTACTSTRUCT* acs = (ADDCONTACTSTRUCT*)mir_alloc(sizeof(ADDCONTACTSTRUCT));
- memmove(acs, (ADDCONTACTSTRUCT*)lParam, sizeof(ADDCONTACTSTRUCT));
- if (acs->psr) {
- PROTOSEARCHRESULT *psr;
- /* bad! structures that are bigger than psr will cause crashes if they define pointers within unreachable structural space */
- psr = (PROTOSEARCHRESULT *)mir_alloc(acs->psr->cbSize);
- memmove(psr, acs->psr, acs->psr->cbSize);
- psr->nick = psr->flags & PSR_UNICODE ? mir_u2t((wchar_t*)psr->nick) : mir_a2t((char*)psr->nick);
- psr->firstName = psr->flags & PSR_UNICODE ? mir_u2t((wchar_t*)psr->firstName) : mir_a2t((char*)psr->firstName);
- psr->lastName = psr->flags & PSR_UNICODE ? mir_u2t((wchar_t*)psr->lastName) : mir_a2t((char*)psr->lastName);
- psr->email = psr->flags & PSR_UNICODE ? mir_u2t((wchar_t*)psr->email) : mir_a2t((char*)psr->email);
- psr->flags = psr->flags & ~PSR_UNICODE | PSR_TCHAR;
- acs->psr = psr;
- /* copied the passed acs structure, the psr structure with, the pointers within that */
- }
-
- if (wParam)
- DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ADDCONTACT), (HWND)wParam, AddContactDlgProc, (LPARAM)acs);
- else
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDCONTACT), (HWND)wParam, AddContactDlgProc, (LPARAM)acs);
- return 0;
+ if (lParam == 0)
+ return 1;
+
+ ADDCONTACTSTRUCT *acs = (ADDCONTACTSTRUCT*)mir_alloc(sizeof(ADDCONTACTSTRUCT));
+ memmove(acs, (ADDCONTACTSTRUCT*)lParam, sizeof(ADDCONTACTSTRUCT));
+ if (acs->psr) {
+ // bad! structures that are bigger than psr will cause crashes if they define pointers within unreachable structural space
+ PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT*)mir_alloc(acs->psr->cbSize);
+ memmove(psr, acs->psr, acs->psr->cbSize);
+ psr->nick = psr->flags & PSR_UNICODE ? mir_u2t((wchar_t*)psr->nick) : mir_a2t((char*)psr->nick);
+ psr->firstName = psr->flags & PSR_UNICODE ? mir_u2t((wchar_t*)psr->firstName) : mir_a2t((char*)psr->firstName);
+ psr->lastName = psr->flags & PSR_UNICODE ? mir_u2t((wchar_t*)psr->lastName) : mir_a2t((char*)psr->lastName);
+ psr->email = psr->flags & PSR_UNICODE ? mir_u2t((wchar_t*)psr->email) : mir_a2t((char*)psr->email);
+ psr->flags = psr->flags & ~PSR_UNICODE | PSR_TCHAR;
+ acs->psr = psr;
+ /* copied the passed acs structure, the psr structure with, the pointers within that */
}
- return 1;
+
+ if (wParam)
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ADDCONTACT), (HWND)wParam, AddContactDlgProc, (LPARAM)acs);
+ else
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDCONTACT), (HWND)wParam, AddContactDlgProc, (LPARAM)acs);
+ return 0;
}
int LoadAddContactModule(void)