aboutsummaryrefslogtreecommitdiffstats
path: root/src/native/addrbook/msoutlook
diff options
context:
space:
mode:
authorVincent Lucas <chenzo@jitsi.org>2013-07-03 11:44:43 +0200
committerVincent Lucas <chenzo@jitsi.org>2013-07-03 11:44:43 +0200
commit284b758a64dd19bc3243913a0df7f16a91829e16 (patch)
tree0814cb72174d9dcacd808b63a3cde39be014f178 /src/native/addrbook/msoutlook
parentf9ddd14566f61c59d9b8e3d097d1451e25cc3b2b (diff)
downloadjitsi-284b758a64dd19bc3243913a0df7f16a91829e16.zip
jitsi-284b758a64dd19bc3243913a0df7f16a91829e16.tar.gz
jitsi-284b758a64dd19bc3243913a0df7f16a91829e16.tar.bz2
Corrects memory leaks fro the Outlook address book plugin.
Diffstat (limited to 'src/native/addrbook/msoutlook')
-rw-r--r--src/native/addrbook/msoutlook/MAPINotification.cxx178
-rw-r--r--src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx132
-rw-r--r--src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx114
-rw-r--r--src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.cxx11
-rw-r--r--src/native/addrbook/msoutlook/com/ComClient.cxx3
-rw-r--r--src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx4
-rw-r--r--src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx4
-rw-r--r--src/native/addrbook/msoutlook/com/server/Server.cxx7
-rw-r--r--src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx1
9 files changed, 220 insertions, 234 deletions
diff --git a/src/native/addrbook/msoutlook/MAPINotification.cxx b/src/native/addrbook/msoutlook/MAPINotification.cxx
index 6a41458..a06455d 100644
--- a/src/native/addrbook/msoutlook/MAPINotification.cxx
+++ b/src/native/addrbook/msoutlook/MAPINotification.cxx
@@ -34,8 +34,10 @@ static ULONG MAPINotification_EVENT_MASK
| fnevObjectCopied;
static LPMDB * MAPINotification_msgStores = NULL;
+static LPMAPIADVISESINK * MAPINotification_adviseSinks = NULL;
static ULONG * MAPINotification_msgStoresConnection = NULL;
static LPMAPITABLE MAPINotification_msgStoresTable = NULL;
+static LPMAPIADVISESINK MAPINotification_msgStoresTableAdviseSink = NULL;
static ULONG MAPINotification_msgStoresTableConnection = 0;
static ULONG MAPINotification_nbMsgStores = 0;
static jmethodID MAPINotification_notificationsDelegateMethodIdDeleted = NULL;
@@ -49,11 +51,10 @@ void (*MAPINotification_callDeletedMethod)(LPSTR iUnknown) = NULL;
void (*MAPINotification_callInsertedMethod)(LPSTR iUnknown) = NULL;
void (*MAPINotification_callUpdatedMethod)(LPSTR iUnknown) = NULL;
-LPUNKNOWN
-MAPINotification_openEntry
- (ULONG cbEntryID, LPENTRYID lpEntryID, LPVOID lpvContext);
-ULONG MAPINotification_registerNotifyMessageDataBase(LPMDB iUnknown);
-ULONG MAPINotification_registerNotifyTable(LPMAPITABLE iUnknown);
+ULONG MAPINotification_registerNotifyMessageDataBase
+ (LPMDB iUnknown, LPMAPIADVISESINK * adviseSink);
+ULONG MAPINotification_registerNotifyTable
+ (LPMAPITABLE iUnknown, LPMAPIADVISESINK * adviseSink);
LONG STDAPICALLTYPE MAPINotification_tableChanged
(LPVOID lpvContext, ULONG cNotifications, LPNOTIFICATION lpNotifications);
@@ -102,6 +103,8 @@ boolean MAPINotification_callCallbackMethod(LPSTR iUnknown, void * object)
ptrOutlookContactCallbackMethodIdCallback,
value);
}
+
+ tmpJniEnv->DeleteLocalRef(callbackClass);
}
}
MAPINotification_VM->DetachCurrentThread();
@@ -133,6 +136,8 @@ void MAPINotification_jniCallDeletedMethod(LPSTR iUnknown)
MAPINotification_notificationsDelegateMethodIdDeleted,
value);
+ tmpJniEnv->DeleteLocalRef(value);
+
MAPINotification_VM->DetachCurrentThread();
}
}
@@ -156,6 +161,8 @@ void MAPINotification_jniCallInsertedMethod(LPSTR iUnknown)
MAPINotification_notificationsDelegateMethodIdInserted,
value);
+ tmpJniEnv->DeleteLocalRef(value);
+
MAPINotification_VM->DetachCurrentThread();
}
}
@@ -179,6 +186,8 @@ void MAPINotification_jniCallUpdatedMethod(LPSTR iUnknown)
MAPINotification_notificationsDelegateMethodIdUpdated,
value);
+ tmpJniEnv->DeleteLocalRef(value);
+
MAPINotification_VM->DetachCurrentThread();
}
}
@@ -196,15 +205,6 @@ STDAPICALLTYPE MAPINotification_onNotify
{
for(unsigned int i = 0; i < cNotifications; ++i)
{
- LPUNKNOWN iUnknown = NULL;
- if(lpvContext != NULL)
- {
- iUnknown = MAPINotification_openEntry(
- lpNotifications[i].info.obj.cbEntryID,
- lpNotifications[i].info.obj.lpEntryID,
- lpvContext);
- }
-
// A contact has been created (a new one or a copy).
if(lpNotifications[i].ulEventType == fnevObjectCreated
|| lpNotifications[i].ulEventType == fnevObjectCopied)
@@ -212,7 +212,7 @@ STDAPICALLTYPE MAPINotification_onNotify
if(lpvContext != NULL)
{
LPSTR entryIdStr = (LPSTR)
- ::malloc(lpNotifications[i].info.obj.cbEntryID * 2 + 1);
+ ::malloc((lpNotifications[i].info.obj.cbEntryID + 1) * 2);
HexFromBin(
(LPBYTE) lpNotifications[i].info.obj.lpEntryID,
@@ -235,7 +235,7 @@ STDAPICALLTYPE MAPINotification_onNotify
if(lpvContext != NULL)
{
LPSTR entryIdStr = (LPSTR)
- ::malloc(lpNotifications[i].info.obj.cbEntryID * 2 + 1);
+ ::malloc((lpNotifications[i].info.obj.cbEntryID + 1) * 2);
HexFromBin(
(LPBYTE) lpNotifications[i].info.obj.lpEntryID,
@@ -282,7 +282,7 @@ STDAPICALLTYPE MAPINotification_onNotify
if(lpvContext != NULL)
{
LPSTR entryIdStr = (LPSTR)
- ::malloc(lpNotifications[i].info.obj.cbEntryID * 2 + 1);
+ ::malloc((lpNotifications[i].info.obj.cbEntryID + 1) * 2);
HexFromBin(
(LPBYTE) lpNotifications[i].info.obj.lpEntryID,
@@ -309,37 +309,32 @@ STDAPICALLTYPE MAPINotification_onNotify
if(lpvContext != NULL)
{
LPSTR entryIdStr = (LPSTR)
- ::malloc(lpNotifications[i].info.obj.cbEntryID * 2 + 1);
+ ::malloc((lpNotifications[i].info.obj.cbEntryID + 1) * 2);
HexFromBin(
(LPBYTE) lpNotifications[i].info.obj.lpEntryID,
lpNotifications[i].info.obj.cbEntryID,
entryIdStr);
LPSTR parentEntryIdStr = (LPSTR)
- ::malloc(lpNotifications[i].info.obj.cbParentID * 2 + 1);
+ ::malloc((lpNotifications[i].info.obj.cbParentID + 1) * 2);
HexFromBin(
(LPBYTE) lpNotifications[i].info.obj.lpParentID,
lpNotifications[i].info.obj.cbParentID,
parentEntryIdStr);
ULONG wasteBasketTags[] = {1, PR_IPM_WASTEBASKET_ENTRYID};
ULONG wasteBasketNbValues = 0;
- LPSPropValue wasteBasketProps = NULL;
+ LPSPropValue wasteBasketProps = NULL;
((LPMDB)lpvContext)->GetProps(
(LPSPropTagArray) wasteBasketTags,
MAPI_UNICODE,
&wasteBasketNbValues,
&wasteBasketProps);
- LPSTR wasteBasketEntryIdStr
- = (LPSTR)::malloc(wasteBasketProps[0].Value.bin.cb * 2 + 1);
+ LPSTR wasteBasketEntryIdStr = (LPSTR)
+ ::malloc((wasteBasketProps[0].Value.bin.cb + 1) * 2);
HexFromBin(
(LPBYTE) wasteBasketProps[0].Value.bin.lpb,
wasteBasketProps[0].Value.bin.cb,
wasteBasketEntryIdStr);
- MAPINotification_openEntry(
- lpNotifications[i].info.obj.cbParentID,
- lpNotifications[i].info.obj.lpParentID,
- lpvContext);
-
fprintf(stdout,
"MAPINotification_onNotify: evMoved: bin %s / %s / %s\n",
entryIdStr,
@@ -347,48 +342,6 @@ STDAPICALLTYPE MAPINotification_onNotify
wasteBasketEntryIdStr);
fflush(stdout);
- LPUNKNOWN entryDirBin =
- MAPINotification_openEntry(
- lpNotifications[i].info.obj.cbEntryID,
- (LPENTRYID) lpNotifications[i].info.obj.lpEntryID,
- lpvContext);
- char* entryDir
- = MsOutlookAddrBookContactQuery_getStringUnicodeProp(
- entryDirBin,
- 0x3001); // PR_DISPLAY_NAME
-
- LPUNKNOWN parentEntryDirBin =
- MAPINotification_openEntry(
- lpNotifications[i].info.obj.cbParentID,
- (LPENTRYID) lpNotifications[i].info.obj.lpParentID,
- lpvContext);
- char* parentEntryDir
- = MsOutlookAddrBookContactQuery_getStringUnicodeProp(
- parentEntryDirBin,
- 0x3001); // PR_DISPLAY_NAME
-
- LPUNKNOWN basketEntryDirBin =
- MAPINotification_openEntry(
- wasteBasketProps[0].Value.bin.cb,
- (LPENTRYID) wasteBasketProps[0].Value.bin.lpb,
- lpvContext);
- char* basketEntryDir
- = MsOutlookAddrBookContactQuery_getStringUnicodeProp(
- basketEntryDirBin,
- 0x3001); // PR_DISPLAY_NAME
-
- fprintf(stdout,
- "MAPINotification_onNotify: evMoved: %s / %s / %s\n",
- entryDir,
- parentEntryDir,
- basketEntryDir);
- fflush(stdout);
-
- free(entryDir);
- free(parentEntryDir);
- free(basketEntryDir);
-
-
if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE
&& strcmp(parentEntryIdStr, wasteBasketEntryIdStr) == 0
&& MAPINotification_callDeletedMethod != NULL)
@@ -402,6 +355,7 @@ STDAPICALLTYPE MAPINotification_onNotify
parentEntryIdStr = NULL;
::free(wasteBasketEntryIdStr);
wasteBasketEntryIdStr = NULL;
+ MAPIFreeBuffer(wasteBasketProps);
// If the entry identifier has changed, then deletes the old
// one.
@@ -428,11 +382,6 @@ STDAPICALLTYPE MAPINotification_onNotify
}
}
}
-
- if(iUnknown != NULL)
- {
- iUnknown->Release();
- }
}
// A client must always return a S_OK.
@@ -440,34 +389,6 @@ STDAPICALLTYPE MAPINotification_onNotify
}
/**
- * Opens an object from its entry id.
- */
-LPUNKNOWN
-MAPINotification_openEntry
- (ULONG cbEntryID, LPENTRYID lpEntryID, LPVOID lpvContext)
-{
- if(lpvContext != NULL)
- {
- LPUNKNOWN iUnknown;
- ULONG objType;
-
- HRESULT hResult =
- ((LPMDB) lpvContext)->OpenEntry(
- cbEntryID,
- lpEntryID,
- NULL,
- MAPINotification_openEntryUlFlags,
- &objType,
- &iUnknown);
- if (HR_SUCCEEDED(hResult))
- {
- return iUnknown;
- }
- }
- return NULL;
-}
-
-/**
* Registers java callback functions when a contact is deleted, inserted or
* updated.
*
@@ -519,6 +440,8 @@ MAPINotification_registerJniNotificationsDelegate
= MAPINotification_jniCallInsertedMethod;
MAPINotification_callUpdatedMethod
= MAPINotification_jniCallUpdatedMethod;
+
+ jniEnv->DeleteLocalRef(callbackClass);
}
}
}
@@ -560,7 +483,8 @@ void MAPINotification_registerNotifyAllMsgStores(LPMAPISESSION mapiSession)
{
MAPINotification_msgStoresTableConnection
= MAPINotification_registerNotifyTable(
- MAPINotification_msgStoresTable);
+ MAPINotification_msgStoresTable,
+ &MAPINotification_msgStoresTableAdviseSink);
hResult = MAPINotification_msgStoresTable->SeekRow(
BOOKMARK_BEGINNING,
0,
@@ -590,6 +514,12 @@ void MAPINotification_registerNotifyAllMsgStores(LPMAPISESSION mapiSession)
MAPINotification_msgStoresConnection,
0,
rows->cRows * sizeof(ULONG));
+ MAPINotification_adviseSinks = (LPMAPIADVISESINK*)
+ malloc(rows->cRows * sizeof(LPMAPIADVISESINK));
+ memset(
+ MAPINotification_adviseSinks,
+ 0,
+ rows->cRows * sizeof(LPMAPIADVISESINK));
if(MAPINotification_msgStores != NULL
&& MAPINotification_msgStoresConnection != NULL)
@@ -630,7 +560,8 @@ void MAPINotification_registerNotifyAllMsgStores(LPMAPISESSION mapiSession)
{
MAPINotification_msgStoresConnection[r]
= MAPINotification_registerNotifyMessageDataBase(
- MAPINotification_msgStores[r]);
+ MAPINotification_msgStores[r],
+ &MAPINotification_adviseSinks[r]);
}
}
}
@@ -646,22 +577,25 @@ void MAPINotification_registerNotifyAllMsgStores(LPMAPISESSION mapiSession)
* Registers to notification for the given message data base.
*
* @param iUnknown The data base to register to in order to receive events.
+ * @param adviseSink The advice sink that will be generated resulting o fthis
+ * function call.
*
* @return A unsigned long which is a token wich must be used to call the
* unadvise function for the same message data base.
*/
-ULONG MAPINotification_registerNotifyMessageDataBase(LPMDB iUnknown)
+ULONG MAPINotification_registerNotifyMessageDataBase(
+ LPMDB iUnknown,
+ LPMAPIADVISESINK * adviseSink)
{
- LPMAPIADVISESINK adviseSink;
- HrAllocAdviseSink(&MAPINotification_onNotify, iUnknown, &adviseSink);
+ HrAllocAdviseSink(&MAPINotification_onNotify, iUnknown, adviseSink);
ULONG nbConnection = 0;
iUnknown->Advise(
(ULONG) 0,
(LPENTRYID) NULL,
MAPINotification_EVENT_MASK,
- adviseSink,
+ *adviseSink,
(ULONG *) &nbConnection);
return nbConnection;
@@ -669,19 +603,22 @@ ULONG MAPINotification_registerNotifyMessageDataBase(LPMDB iUnknown)
/**
* Registers a callback function for when the message store table changes.
+ *
+ * @param iUnknown The message store table to register to in order to receive
+ * events.
+ * @param adviseSink The advice sink that will be generated resulting o fthis
+ * function call.
+ *
+ * @return A unsigned long which is a token wich must be used to call the
+ * unadvise function for the same message store table.
*/
-ULONG MAPINotification_registerNotifyTable(LPMAPITABLE iUnknown)
+ULONG MAPINotification_registerNotifyTable(
+ LPMAPITABLE iUnknown,
+ LPMAPIADVISESINK * adviseSink)
{
- LPMAPIADVISESINK adviseSink;
- HrAllocAdviseSink(
- &MAPINotification_tableChanged,
- iUnknown,
- &adviseSink);
+ HrAllocAdviseSink(&MAPINotification_tableChanged, iUnknown, adviseSink);
ULONG nbConnection = 0;
- iUnknown->Advise(
- fnevTableModified,
- adviseSink,
- (ULONG *) &nbConnection);
+ iUnknown->Advise(fnevTableModified, *adviseSink, (ULONG *) &nbConnection);
return nbConnection;
}
@@ -748,10 +685,13 @@ void MAPINotification_unregisterNotifyAllMsgStores(void)
{
if(MAPINotification_msgStoresConnection[i] != 0)
{
+ MAPINotification_adviseSinks[i]->Release();
MAPINotification_msgStores[i]->Unadvise(
MAPINotification_msgStoresConnection[i]);
}
}
+ free(MAPINotification_adviseSinks);
+ MAPINotification_adviseSinks = NULL;
free(MAPINotification_msgStoresConnection);
MAPINotification_msgStoresConnection = NULL;
}
@@ -771,6 +711,8 @@ void MAPINotification_unregisterNotifyAllMsgStores(void)
if(MAPINotification_msgStoresTable != NULL)
{
+ MAPINotification_msgStoresTableAdviseSink->Release();
+ MAPINotification_msgStoresTableAdviseSink = NULL;
MAPINotification_msgStoresTable->Unadvise(
MAPINotification_msgStoresTableConnection);
MAPINotification_msgStoresTable->Release();
diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx
index c62da65..378ee0e 100644
--- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx
+++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx
@@ -323,11 +323,13 @@ HRESULT MsOutlookAddrBookContactQuery_createEmailAddress
}
if (spvProps[6].Value.bin.lpb)
+ {
free(spvProps[6].Value.bin.lpb);
+ }
+ MAPIFreeBuffer(lpNamedPropTags);
}
- MAPIFreeBuffer(lpNamedPropTags);
- MAPIFreeBuffer(&parentId);
+ MAPIFreeBuffer(parentId.lpb);
parentEntry->Release();
return hRes;
@@ -377,8 +379,8 @@ int MsOutlookAddrBookContactQuery_deleteContact(const char * nativeEntryId)
DELETE_HARD_DELETE) == S_OK);
((LPMAPIPROP) parentEntry)->Release();
- MAPIFreeBuffer(&parentId);
- MAPIFreeBuffer(&contactId);
+ MAPIFreeBuffer(parentId.lpb);
+ MAPIFreeBuffer(contactId.lpb);
((LPMAPIPROP) mapiProp)->Release();
return res;
@@ -773,6 +775,8 @@ MsOutlookAddrBookContactQuery_getAttachmentContactPhoto
void MsOutlookAddrBookContactQuery_getBinaryProp
(LPMAPIPROP entry, ULONG propId, LPSBinary binaryProp)
{
+ binaryProp->cb = 0;
+
SPropTagArray tagArray;
tagArray.cValues = 1;
tagArray.aulPropTag[0] = PROP_TAG(PT_BINARY, propId);
@@ -788,8 +792,13 @@ void MsOutlookAddrBookContactQuery_getBinaryProp
if (HR_SUCCEEDED(hResult))
{
SPropValue prop = propArray[0];
- binaryProp->cb = prop.Value.bin.cb;
- binaryProp->lpb = prop.Value.bin.lpb;
+ if(MAPIAllocateBuffer(prop.Value.bin.cb, (void **) &binaryProp->lpb)
+ == S_OK)
+ {
+ binaryProp->cb = prop.Value.bin.cb;
+ memcpy(binaryProp->lpb, prop.Value.bin.lpb, binaryProp->cb);
+ }
+ MAPIFreeBuffer(propArray);
}
}
@@ -863,6 +872,7 @@ LPSTR MsOutlookAddrBookContactQuery_getContactId(LPMAPIPROP contact)
{
entryId = (LPSTR)::malloc(binaryProp.cb * 2 + 1);
HexFromBin(binaryProp.lpb, binaryProp.cb, entryId);
+ MAPIFreeBuffer(binaryProp.lpb);
}
return entryId;
@@ -1108,6 +1118,7 @@ MsOutlookAddrBookContactQuery_HrGetOneProp(
}
if (!propHasBeenAssignedTo)
hResult = MAPI_E_NOT_FOUND;
+ MAPIFreeBuffer(values);
}
return hResult;
}
@@ -1375,8 +1386,8 @@ HRESULT MsOutlookAddrBookContactQuery_IMAPIProp_1GetProps(
propArray++;
MAPIFreeBuffer(prop);
}
+ MAPIFreeBuffer(propTagArray);
}
- MAPIFreeBuffer(propTagArray);
}
}
((LPMAPIPROP) mapiProp)->Release();
@@ -1414,6 +1425,7 @@ int MsOutlookAddrBookContactQuery_IMAPIProp_1SetPropString
"setPropUnicode (addrbook/MsOutlookAddrBookContactQuery.c): \
\n\tmbstowcs\n");
fflush(stderr);
+ ((LPMAPIPROP) mapiProp)->Release();
::free(wCharValue);
wCharValue = NULL;
return 0;
@@ -1507,13 +1519,18 @@ int MsOutlookAddrBookContactQuery_IMAPIProp_1SetPropString
propIds,
7) == S_OK)
{
+ MAPIFreeBuffer(propArray);
MAPIFreeBuffer(propTagArray);
((LPMAPIPROP) mapiProp)->Release();
+ ::free(wCharValue);
+ wCharValue = NULL;
return 1;
}
}
MAPIFreeBuffer(propTagArray);
((LPMAPIPROP) mapiProp)->Release();
+ ::free(wCharValue);
+ wCharValue = NULL;
return 0;
}
@@ -1540,6 +1557,7 @@ int MsOutlookAddrBookContactQuery_IMAPIProp_1SetPropString
((LPMAPIPROP) mapiProp)->Release();
::free(wCharValue);
wCharValue = NULL;
+
return 1;
}
}
@@ -1570,8 +1588,7 @@ MsOutlookAddrBookContactQuery_onForeachContactInMsgStoresTableRow
// succeed.
jboolean proceed = JNI_TRUE;
- hResult
- = ((LPMAPISESSION) mapiSession)->OpenMsgStore(
+ hResult = ((LPMAPISESSION) mapiSession)->OpenMsgStore(
0,
entryIDByteCount, entryID,
NULL,
@@ -1583,46 +1600,51 @@ MsOutlookAddrBookContactQuery_onForeachContactInMsgStoresTableRow
ULONG contactsFolderEntryIDByteCount = 0;
LPENTRYID contactsFolderEntryID = NULL;
- hResult
- = msgStore->GetReceiveFolder(
+ hResult = msgStore->GetReceiveFolder(
NULL,
0,
- &entryIDByteCount, &receiveFolderEntryID,
+ &entryIDByteCount,
+ &receiveFolderEntryID,
NULL);
if (HR_SUCCEEDED(hResult))
{
- hResult
- = MsOutlookAddrBookContactQuery_getContactsFolderEntryID(
+ hResult = MsOutlookAddrBookContactQuery_getContactsFolderEntryID(
msgStore,
- entryIDByteCount, receiveFolderEntryID,
- &contactsFolderEntryIDByteCount, &contactsFolderEntryID);
+ entryIDByteCount,
+ receiveFolderEntryID,
+ &contactsFolderEntryIDByteCount,
+ &contactsFolderEntryID);
MAPIFreeBuffer(receiveFolderEntryID);
}
if (HR_FAILED(hResult))
{
- hResult
- = MsOutlookAddrBookContactQuery_getContactsFolderEntryID(
+ hResult = MsOutlookAddrBookContactQuery_getContactsFolderEntryID(
msgStore,
- 0, NULL,
- &contactsFolderEntryIDByteCount, &contactsFolderEntryID);
+ 0,
+ NULL,
+ &contactsFolderEntryIDByteCount,
+ &contactsFolderEntryID);
}
if (HR_SUCCEEDED(hResult))
{
ULONG contactsFolderObjType;
LPUNKNOWN contactsFolder;
- hResult
- = msgStore->OpenEntry(
- contactsFolderEntryIDByteCount, contactsFolderEntryID,
+ hResult = msgStore->OpenEntry(
+ contactsFolderEntryIDByteCount,
+ contactsFolderEntryID,
NULL,
MsOutlookAddrBookContactQuery_openEntryUlFlags,
- &contactsFolderObjType, &contactsFolder);
+ &contactsFolderObjType,
+ &contactsFolder);
if (HR_SUCCEEDED(hResult))
{
- proceed
- = MsOutlookAddrBookContactQuery_foreachMailUser(
- contactsFolderObjType, contactsFolder,
- query, callback, callbackObject);
+ proceed = MsOutlookAddrBookContactQuery_foreachMailUser(
+ contactsFolderObjType,
+ contactsFolder,
+ query,
+ callback,
+ callbackObject);
contactsFolder->Release();
}
MAPIFreeBuffer(contactsFolderEntryID);
@@ -1644,18 +1666,21 @@ MsOutlookAddrBookContactQuery_onForeachMailUserInContainerTableRow
jboolean proceed;
// Make write failed and image load.
- hResult
- = ((LPMAPICONTAINER) mapiContainer)->OpenEntry(
- entryIDByteCount, entryID,
+ hResult = ((LPMAPICONTAINER) mapiContainer)->OpenEntry(
+ entryIDByteCount,
+ entryID,
NULL,
MsOutlookAddrBookContactQuery_openEntryUlFlags,
- &objType, &iUnknown);
+ &objType,
+ &iUnknown);
if (HR_SUCCEEDED(hResult))
{
- proceed
- = MsOutlookAddrBookContactQuery_foreachMailUser(
- objType, iUnknown,
- query, callback, callbackObject);
+ proceed = MsOutlookAddrBookContactQuery_foreachMailUser(
+ objType,
+ iUnknown,
+ query,
+ callback,
+ callbackObject);
iUnknown->Release();
}
else
@@ -1679,12 +1704,16 @@ LPUNKNOWN MsOutlookAddrBookContactQuery_openEntryIdStr(const char* entryIdStr)
ULONG entryIdSize = strlen(entryIdStr) / 2;
LPENTRYID entryId = (LPENTRYID) malloc(entryIdSize * sizeof(char));
- if(FBinFromHex((LPSTR) entryIdStr, (LPBYTE) entryId))
+ if(entryId != NULL)
{
- entry = MsOutlookAddrBookContactQuery_openEntryId(entryIdSize, entryId);
+ if(FBinFromHex((LPSTR) entryIdStr, (LPBYTE) entryId))
+ {
+ entry = MsOutlookAddrBookContactQuery_openEntryId(
+ entryIdSize,
+ entryId);
+ }
+ ::free(entryId);
}
-
- ::free(entryId);
return entry;
}
@@ -1832,10 +1861,12 @@ char* MsOutlookAddrBookContactQuery_getStringUnicodeProp
"getStringUnicodeProp (addrbook/MsOutlookAddrBookContactQuery.c): \
\n\tmbstowcs\n");
fflush(stderr);
+ MAPIFreeBuffer(propArray);
::free(value);
value = NULL;
return NULL;
}
+ MAPIFreeBuffer(propArray);
return value;
}
@@ -1856,17 +1887,6 @@ int MsOutlookAddrBookContactQuery_compareEntryIds(
LPSTR id1,
LPSTR id2)
{
- if(strcmp(id1, id2) == 0)
- {
- fprintf(stderr,
- "CHENZO compareEntryIds: \
- \n\tid1: %s\
- \n\tid2: %s\n",
- id1,
- id2);
- fflush(stderr);
- }
- //id2 = "ROH";
int result = 0;
LPMAPISESSION session = MAPISession_getMapiSession();
@@ -1886,6 +1906,8 @@ int MsOutlookAddrBookContactQuery_compareEntryIds(
MsOutlookAddrBookContactQuery_openEntryIdStr(id2))
== NULL)
{
+ mapiId1->Release();
+ MAPIFreeBuffer(contactId1.lpb);
return result;
}
SBinary contactId2;
@@ -1907,6 +1929,10 @@ int MsOutlookAddrBookContactQuery_compareEntryIds(
"compareEntryIds (addrbook/MsOutlookAddrBookContactQuery.c): \
\n\tMAPISession::CompareEntryIDs\n");
fflush(stderr);
+ mapiId1->Release();
+ MAPIFreeBuffer(contactId1.lpb);
+ mapiId2->Release();
+ MAPIFreeBuffer(contactId2.lpb);
return result;
}
result = res;
@@ -1924,5 +1950,9 @@ int MsOutlookAddrBookContactQuery_compareEntryIds(
result);
fflush(stderr);
}
+ mapiId1->Release();
+ MAPIFreeBuffer(contactId1.lpb);
+ mapiId2->Release();
+ MAPIFreeBuffer(contactId2.lpb);
return result;
}
diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx
index 1e0e751..7fb9f4c 100644
--- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx
+++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx
@@ -76,13 +76,14 @@ HRESULT MsOutlookAddrBookContactSourceService_MAPIInitialize
DWORD pathValueType;
DWORD pathValueSize;
- regEnumKeyEx
- = RegEnumKeyEx(
+ regEnumKeyEx = RegEnumKeyEx(
regKey,
i,
- installRootKeyName, &subkeyNameLength,
+ installRootKeyName,
+ &subkeyNameLength,
+ NULL,
+ NULL,
NULL,
- NULL, NULL,
NULL);
if (ERROR_NO_MORE_ITEMS == regEnumKeyEx)
break;
@@ -102,63 +103,64 @@ HRESULT MsOutlookAddrBookContactSourceService_MAPIInitialize
KEY_QUERY_VALUE,
&installRootKey))
{
- if ((ERROR_SUCCESS
- == RegQueryValueEx(
- installRootKey,
- _T("Path"),
- NULL,
- &pathValueType,
- NULL, &pathValueSize))
- && (REG_SZ == pathValueType)
- && pathValueSize)
- {
- LPTSTR pathValue;
-
- // MSDN says "the string may not have been stored with the
- // proper terminating null characters."
- pathValueSize
- += sizeof(TCHAR)
- * (12 // \Outlook.exe
- + 1); // The terminating null character
-
- if (pathValueSize <= sizeof(installRootKeyName))
- pathValue = installRootKeyName;
- else
- {
- pathValue = (LPTSTR)::malloc(pathValueSize);
- if (!pathValue)
- continue;
- }
-
- if (ERROR_SUCCESS
+ if ((ERROR_SUCCESS
== RegQueryValueEx(
installRootKey,
_T("Path"),
NULL,
+ &pathValueType,
NULL,
- (LPBYTE) pathValue, &pathValueSize))
+ &pathValueSize))
+ && (REG_SZ == pathValueType)
+ && pathValueSize)
{
- DWORD pathValueLength = pathValueSize / sizeof(TCHAR);
+ LPTSTR pathValue;
+
+ // MSDN says "the string may not have been stored with the
+ // proper terminating null characters."
+ pathValueSize
+ += sizeof(TCHAR)
+ * (12 // \Outlook.exe
+ + 1); // The terminating null character
+
+ if (pathValueSize <= sizeof(installRootKeyName))
+ pathValue = installRootKeyName;
+ else
+ {
+ pathValue = (LPTSTR)::malloc(pathValueSize);
+ if (!pathValue)
+ continue;
+ }
- if (pathValueLength)
+ if (ERROR_SUCCESS
+ == RegQueryValueEx(
+ installRootKey,
+ _T("Path"),
+ NULL,
+ NULL,
+ (LPBYTE) pathValue, &pathValueSize))
{
- DWORD fileAttributes;
+ DWORD pathValueLength = pathValueSize / sizeof(TCHAR);
+
+ if (pathValueLength)
+ {
+ DWORD fileAttributes;
- str = pathValue + (pathValueLength - 1);
- if (*str)
- str++;
- memcpy(str, _T("\\Outlook.exe"), 12 * sizeof(TCHAR));
- *(str + 12) = 0;
+ str = pathValue + (pathValueLength - 1);
+ if (*str)
+ str++;
+ memcpy(str, _T("\\Outlook.exe"), 12 * sizeof(TCHAR));
+ *(str + 12) = 0;
- fileAttributes = GetFileAttributes(pathValue);
- if (INVALID_FILE_ATTRIBUTES != fileAttributes)
- hResult = S_OK;
+ fileAttributes = GetFileAttributes(pathValue);
+ if (INVALID_FILE_ATTRIBUTES != fileAttributes)
+ hResult = S_OK;
+ }
}
- }
- if (pathValue != installRootKeyName)
- free(pathValue);
- }
+ if (pathValue != installRootKeyName)
+ free(pathValue);
+ }
RegCloseKey(installRootKey);
}
}
@@ -187,13 +189,13 @@ HRESULT MsOutlookAddrBookContactSourceService_MAPIInitialize
&regKey))
{
DWORD defaultValueSize = defaultValueCapacity;
- LONG regQueryValueEx
- = RegQueryValueEx(
- regKey,
- NULL,
- NULL,
- &defaultValueType,
- (LPBYTE) defaultValue, &defaultValueSize);
+ LONG regQueryValueEx = RegQueryValueEx(
+ regKey,
+ NULL,
+ NULL,
+ &defaultValueType,
+ (LPBYTE) defaultValue,
+ &defaultValueSize);
switch (regQueryValueEx)
{
diff --git a/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.cxx b/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.cxx
index 9bb591c..706a5de 100644
--- a/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.cxx
+++ b/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.cxx
@@ -81,7 +81,12 @@ MsOutlookMAPIHResultException_throwNew
(jlong) hResult, jmessage);
if (t)
+ {
jniEnv->Throw((jthrowable) t);
+
+ jniEnv->DeleteLocalRef(t);
+ }
+ jniEnv->DeleteLocalRef(jmessage);
}
return;
}
@@ -95,11 +100,17 @@ MsOutlookMAPIHResultException_throwNew
jobject t = jniEnv->NewObject(clazz, methodID, hResult);
if (t)
+ {
jniEnv->Throw((jthrowable) t);
+
+ jniEnv->DeleteLocalRef(t);
+ }
return;
}
}
jniEnv->ThrowNew(clazz, message);
+
+ jniEnv->DeleteLocalRef(clazz);
}
}
diff --git a/src/native/addrbook/msoutlook/com/ComClient.cxx b/src/native/addrbook/msoutlook/com/ComClient.cxx
index 4c3dfcf..af29b3c 100644
--- a/src/native/addrbook/msoutlook/com/ComClient.cxx
+++ b/src/native/addrbook/msoutlook/com/ComClient.cxx
@@ -94,6 +94,7 @@ void ComClient_stop(void)
if(ComClient_classFactory)
{
+ ComClient_classFactory->revokeClassObject();
ComClient_classFactory->Release();
ComClient_classFactory = NULL;
}
@@ -102,6 +103,8 @@ void ComClient_stop(void)
TypeLib_releaseTypeLib(ComClient_typeLib);
ComClient_typeLib = NULL;
}
+
+ CoUninitialize();
}
/**
diff --git a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx
index fccaa9c..03f0b49 100644
--- a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx
+++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx
@@ -41,10 +41,6 @@ MsOutlookAddrBookClient::~MsOutlookAddrBookClient()
*/
STDMETHODIMP MsOutlookAddrBookClient::QueryInterface(REFIID iid, PVOID *obj)
{
- OLECHAR* strGuid;
- StringFromCLSID(iid, &strGuid);
- ::CoTaskMemFree(strGuid);
-
HRESULT hr;
if (!obj)
diff --git a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx
index ebd7aa5..288ef47 100644
--- a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx
+++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx
@@ -43,10 +43,6 @@ MsOutlookAddrBookServer::~MsOutlookAddrBookServer()
*/
STDMETHODIMP MsOutlookAddrBookServer::QueryInterface(REFIID iid, PVOID *obj)
{
- OLECHAR* strGuid;
- StringFromCLSID(iid, &strGuid);
- ::CoTaskMemFree(strGuid);
-
HRESULT hr;
if (!obj)
diff --git a/src/native/addrbook/msoutlook/com/server/Server.cxx b/src/native/addrbook/msoutlook/com/server/Server.cxx
index d33c1b4..6ffb503 100644
--- a/src/native/addrbook/msoutlook/com/server/Server.cxx
+++ b/src/native/addrbook/msoutlook/com/server/Server.cxx
@@ -44,6 +44,7 @@ int main(int argc, char** argv)
(void*) Server_updated)
!= S_OK)
{
+ CoUninitialize();
return hr;
}
@@ -60,6 +61,7 @@ int main(int argc, char** argv)
waitParentProcessStop();
hr = ::CoSuspendClassObjects();
+ hr = classObject->revokeClassObject();
classObject->Release();
}
@@ -68,6 +70,8 @@ int main(int argc, char** argv)
MsOutlookAddrBookContactSourceService_NativeMAPIUninitialize();
MAPISession_freeLock();
+ CoUninitialize();
+
return hr;
}
@@ -107,13 +111,14 @@ void waitParentProcessStop()
WaitForSingleObject(parentHandle, INFINITE);
GetExitCodeProcess(parentHandle, &exitCode);
}
+ CloseHandle(parentHandle);
return;
}
}
while(Process32Next(handle, &processEntry));
}
+ CloseHandle(handle);
}
- CloseHandle(handle);
}
/**
diff --git a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx
index 429bb74..0d43d67 100644
--- a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx
+++ b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx
@@ -211,6 +211,7 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac
if(jniEnv->ExceptionCheck())
{
+ jniEnv->ReleaseStringUTFChars(entryId, nativeEntryId);
return NULL;
}