From fa906d9bf4baec75ba72bed046d3fb5f794206a8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 19 Dec 2013 19:47:56 +0000 Subject: crash on send git-svn-id: http://svn.miranda-ng.org/main/trunk@7289 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/ContactsPlus/src/send.cpp | 4 ++-- plugins/ContactsPlus/src/utils.cpp | 10 ++++++++-- plugins/ContactsPlus/src/utils.h | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/ContactsPlus/src/send.cpp b/plugins/ContactsPlus/src/send.cpp index 4ee9b17b91..d391edb177 100644 --- a/plugins/ContactsPlus/src/send.cpp +++ b/plugins/ContactsPlus/src/send.cpp @@ -444,9 +444,9 @@ INT_PTR CALLBACK SendDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara } dbei.pBlob = (PBYTE)_alloca(dbei.cbBlob); for (i = 0, pBlob = (char*)dbei.pBlob; i < ackData->nContacts; i++) { - strcpy(pBlob, (char*)maSend[i].mcaNick); + strcpynull(pBlob, (char*)maSend[i].mcaNick); pBlob += strlennull(pBlob) + 1; - strcpy(pBlob, maSend[i].mcaUIN); + strcpynull(pBlob, maSend[i].mcaUIN); pBlob += strlennull(pBlob) + 1; } db_event_add(ackData->hContact, &dbei); diff --git a/plugins/ContactsPlus/src/utils.cpp b/plugins/ContactsPlus/src/utils.cpp index dcfdda958b..e72c1ed7b3 100644 --- a/plugins/ContactsPlus/src/utils.cpp +++ b/plugins/ContactsPlus/src/utils.cpp @@ -23,8 +23,6 @@ #include "contacts.h" -int utf8_decode(const unsigned char *from, char **to); - /* a strlennull() that likes NULL */ size_t __fastcall strlennull(const char *string) { @@ -41,6 +39,14 @@ int __fastcall strcmpnull(const char *str1, const char *str2) return strcmp(str1, str2); } +void __fastcall strcpynull(char *str1, const char *str2) +{ + if (!str2) + str2 = ""; + + strcpy(str1, str2); +} + char* __fastcall null_strdup(const char *string) { if (string) diff --git a/plugins/ContactsPlus/src/utils.h b/plugins/ContactsPlus/src/utils.h index f89ee6ca9b..ceffbe3502 100644 --- a/plugins/ContactsPlus/src/utils.h +++ b/plugins/ContactsPlus/src/utils.h @@ -29,6 +29,7 @@ extern HINSTANCE hInst; // utils.cpp size_t __fastcall strlennull(const char *string); int __fastcall strcmpnull(const char *str1, const char *str2); +void __fastcall strcpynull(char *str1, const char *str2); char* __fastcall null_strdup(const char *string); TCHAR* GetContactUID(HANDLE hContact); -- cgit v1.2.3