aboutsummaryrefslogtreecommitdiffstats
path: root/src/native/addrbook/msoutlook
diff options
context:
space:
mode:
authorVincent Lucas <chenzo@jitsi.org>2013-05-29 16:09:38 +0200
committerVincent Lucas <chenzo@jitsi.org>2013-05-29 16:09:38 +0200
commitcc3c615cbc434891e80809c7bc1483a476301821 (patch)
tree25703745f476e8d5afbe419e189c540ad4034844 /src/native/addrbook/msoutlook
parent6e2ef5898dbbbf8b56e0d1004c050b481265e469 (diff)
downloadjitsi-cc3c615cbc434891e80809c7bc1483a476301821.zip
jitsi-cc3c615cbc434891e80809c7bc1483a476301821.tar.gz
jitsi-cc3c615cbc434891e80809c7bc1483a476301821.tar.bz2
Corrects STATUS_ACCESS_VIOLATION error, when failing to get the properties of a MsOutlook contact.
Diffstat (limited to 'src/native/addrbook/msoutlook')
-rw-r--r--src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx1
-rw-r--r--src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx241
2 files changed, 124 insertions, 118 deletions
diff --git a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx
index 17afb32..fb67675 100644
--- a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx
+++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx
@@ -189,6 +189,7 @@ HRESULT STDMETHODCALLTYPE MsOutlookAddrBookServer::IMAPIProp_GetProps(
if((localProps = (void**) malloc(nbPropIds * sizeof(void*))) != NULL)
{
+ memset(localProps, 0, nbPropIds * sizeof(void*));
if((localPropsLength = (unsigned long*) malloc(
nbPropIds * sizeof(unsigned long))) != NULL)
{
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 6aa6e95..a36e7bd 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
@@ -221,6 +221,7 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac
if((props = (void**) malloc(propIdCount * sizeof(void*))) != NULL)
{
+ memset(props, 0, propIdCount * sizeof(void*));
if((propsLength = (unsigned long*) malloc(
propIdCount * sizeof(unsigned long))) != NULL)
{
@@ -253,149 +254,153 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac
&comPropsLength,
&comPropsType);
- SafeArrayLock(comPropsType);
- memcpy(
- propsType,
- comPropsType->pvData,
- propIdCount * sizeof(char));
- SafeArrayUnlock(comPropsType);
- SafeArrayDestroy(comPropsType);
-
- SafeArrayLock(comPropsLength);
- memcpy(
- propsLength,
- comPropsLength->pvData,
- propIdCount * sizeof(unsigned long));
- SafeArrayUnlock(comPropsLength);
- SafeArrayDestroy(comPropsLength);
-
- SafeArrayLock(comProps);
- byte * data = (byte*) comProps->pvData;
- for(int j = 0; j < propIdCount; ++j)
+ if(HR_SUCCEEDED(hr))
{
- if((props[j] = malloc(propsLength[j])) != NULL)
+ SafeArrayLock(comPropsType);
+ memcpy(
+ propsType,
+ comPropsType->pvData,
+ propIdCount * sizeof(char));
+ SafeArrayUnlock(comPropsType);
+
+ SafeArrayLock(comPropsLength);
+ memcpy(
+ propsLength,
+ comPropsLength->pvData,
+ propIdCount * sizeof(unsigned long));
+ SafeArrayUnlock(comPropsLength);
+
+ SafeArrayLock(comProps);
+ byte * data = (byte*) comProps->pvData;
+ for(int j = 0; j < propIdCount; ++j)
{
- memcpy(props[j], data, propsLength[j]);
- data += propsLength[j];
+ if((props[j] = malloc(propsLength[j])) != NULL)
+ {
+ memcpy(props[j], data, propsLength[j]);
+ data += propsLength[j];
+ }
}
- }
- SafeArrayUnlock(comProps);
- SafeArrayDestroy(comProps);
+ SafeArrayUnlock(comProps);
- SafeArrayDestroy(comPropIds);
- SysFreeString(comEntryId);
- free(unicodeEntryId);
- }
-
- if(HR_SUCCEEDED(hr))
- {
- // Decode properties to java
- jclass objectClass = jniEnv->FindClass("java/lang/Object");
- if (objectClass)
- {
- javaProps = jniEnv->NewObjectArray(
- propIdCount,
- objectClass,
- NULL);
- for(int j = 0; j < propIdCount; ++j)
+ // Decode properties to java
+ jclass objectClass
+ = jniEnv->FindClass("java/lang/Object");
+ if (objectClass)
{
- // byte array
- if(propsType[j] == 'b' && props[j] != NULL)
+ javaProps = jniEnv->NewObjectArray(
+ propIdCount,
+ objectClass,
+ NULL);
+ for(int j = 0; j < propIdCount; ++j)
{
- jbyteArray value = jniEnv->NewByteArray(
- (jsize) propsLength[j]);
- if(value)
+ // byte array
+ if(propsType[j] == 'b' && props[j] != NULL)
{
- jbyte *bytes
- = jniEnv->GetByteArrayElements(
- value, NULL);
-
- if (bytes)
+ jbyteArray value = jniEnv->NewByteArray(
+ (jsize) propsLength[j]);
+ if(value)
{
- memcpy(bytes, props[j], propsLength[j]);
- jniEnv->ReleaseByteArrayElements(
- value,
- bytes,
- 0);
- jniEnv->SetObjectArrayElement(
- javaProps,
- j,
- value);
+ jbyte *bytes
+ = jniEnv->GetByteArrayElements(
+ value, NULL);
+
+ if (bytes)
+ {
+ memcpy(
+ bytes,
+ props[j],
+ propsLength[j]);
+ jniEnv->ReleaseByteArrayElements(
+ value,
+ bytes,
+ 0);
+ jniEnv->SetObjectArrayElement(
+ javaProps,
+ j,
+ value);
+ }
}
}
- }
- // long
- else if(propsType[j] == 'l' && props[j] != NULL)
- {
- jclass longClass
- = jniEnv->FindClass("java/lang/Long");
- if (longClass)
+ // long
+ else if(propsType[j] == 'l' && props[j] != NULL)
{
- jmethodID longMethodID
- = jniEnv->GetMethodID(
- longClass,
- "<init>",
- "(J)V");
-
- if (longMethodID)
+ jclass longClass
+ = jniEnv->FindClass("java/lang/Long");
+ if (longClass)
{
- jlong l;
- memcpy(&l, props[j], propsLength[j]);
- jobject value = jniEnv->NewObject(
+ jmethodID longMethodID
+ = jniEnv->GetMethodID(
longClass,
- longMethodID,
- l);
+ "<init>",
+ "(J)V");
- if (value)
+ if (longMethodID)
{
- jniEnv->SetObjectArrayElement(
- javaProps,
- j,
- value);
+ jlong l;
+ memcpy(&l, props[j], propsLength[j]);
+ jobject value = jniEnv->NewObject(
+ longClass,
+ longMethodID,
+ l);
+
+ if (value)
+ {
+ jniEnv->SetObjectArrayElement(
+ javaProps,
+ j,
+ value);
+ }
}
}
}
- }
- // 8 bits string
- else if(propsType[j] == 's' && props[j] != NULL)
- {
- jstring value = jniEnv->NewStringUTF(
- (const char*) props[j]);
- if (value)
+ // 8 bits string
+ else if(propsType[j] == 's' && props[j] != NULL)
{
- jniEnv->SetObjectArrayElement(
- javaProps,
- j,
- value);
+ jstring value = jniEnv->NewStringUTF(
+ (const char*) props[j]);
+ if (value)
+ {
+ jniEnv->SetObjectArrayElement(
+ javaProps,
+ j,
+ value);
+ }
}
- }
- // 16 bits string
- else if(propsType[j] == 'u' && props[j] != NULL)
- {
- jstring value
- = jniEnv->NewString(
- (const jchar *) props[j],
- wcslen((const wchar_t *) props[j]));
- if (value)
+ // 16 bits string
+ else if(propsType[j] == 'u' && props[j] != NULL)
{
- jniEnv->SetObjectArrayElement(
- javaProps,
- j,
- value);
+ jstring value
+ = jniEnv->NewString(
+ (const jchar *) props[j],
+ wcslen((const wchar_t *) props[j]));
+ if (value)
+ {
+ jniEnv->SetObjectArrayElement(
+ javaProps,
+ j,
+ value);
+ }
}
- }
- if(jniEnv->ExceptionCheck())
- javaProps = NULL;
+ if(jniEnv->ExceptionCheck())
+ javaProps = NULL;
+ }
}
}
- }
- else
- {
- MsOutlookMAPIHResultException_throwNew(
- jniEnv,
- hr,
- __FILE__, __LINE__);
+ else
+ {
+ MsOutlookMAPIHResultException_throwNew(
+ jniEnv,
+ hr,
+ __FILE__, __LINE__);
+ }
+
+ SafeArrayDestroy(comPropsType);
+ SafeArrayDestroy(comPropsLength);
+ SafeArrayDestroy(comProps);
+ SafeArrayDestroy(comPropIds);
+ SysFreeString(comEntryId);
+ free(unicodeEntryId);
}