OpenChange: Avoid crashing when creating embedded message in attachment

Signed-off-by: Kamen Mazdrashki <kamenim@samba.org>
(cherry picked from commit 15a55f9f707247c9164e8fa7a102639744f686e5)
pull/49/head
Kamen Mazdrashki 2014-02-22 23:01:41 +01:00 committed by Julio García
parent 6bef678114
commit f8028b5a94
1 changed files with 24 additions and 5 deletions

View File

@ -61,6 +61,17 @@ sogo_backend_unexpected_error()
return MAPISTORE_SUCCESS;
}
static enum mapistore_error
sogo_backend_handle_objc_exception(NSException *e, const char *fn_name, const int line_no)
{
DEBUG(0,("[SOGo: %s:%d] - EXCEPTION: %s, reason: %s\n", fn_name, line_no, [[e name] UTF8String], [[e reason] UTF8String]));
if ([[e name] isEqual:@"NotImplementedException"])
{
return MAPISTORE_ERR_NOT_IMPLEMENTED;
}
return MAPISTORE_ERROR;
}
static void
sogo_backend_atexit (void)
{
@ -73,6 +84,7 @@ sogo_backend_atexit (void)
GSUnregisterCurrentThread ();
}
/**
\details Initialize sogo mapistore backend
@ -1139,11 +1151,18 @@ sogo_message_attachment_create_embedded_message (void *attachment_object,
attachment = wrapper->instance;
GSRegisterCurrentThread ();
pool = [NSAutoreleasePool new];
rc = [attachment createEmbeddedMessage: &message
withMAPIStoreMsg: msg
inMemCtx: mem_ctx];
if (rc == MAPISTORE_SUCCESS)
*message_object = [message tallocWrapper: mem_ctx];
@try
{
rc = [attachment createEmbeddedMessage: &message
withMAPIStoreMsg: msg
inMemCtx: mem_ctx];
if (rc == MAPISTORE_SUCCESS)
*message_object = [message tallocWrapper: mem_ctx];
}
@catch (NSException *e)
{
rc = sogo_backend_handle_objc_exception(e, __FUNCTION__, __LINE__);
}
[pool release];
GSUnregisterCurrentThread ();
}