From fd2f5dfb67430ae7fcd53e8870c696eee06ff53e Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 27 Sep 2011 14:44:53 +0000 Subject: [PATCH] Monotone-Parent: 6ad0713108beb5244446e83f17724cf5b9cee560 Monotone-Revision: e68f0a3422367e930eb3d030ebd4a65ee79e3581 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-09-27T14:44:53 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++++ OpenChange/MAPIStoreFolder.m | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index cd8723c63..448a73e93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2011-09-27 Wolfgang Sourdeau + * OpenChange/MAPIStoreFolder.m + (-moveCopyMessagesWithMID:fromFolder:withMID:wantCopy:): ensure + the message URL exists in the MAPIStoreMapping, otherwise fail + with MAPISTORE_ERR_NOT_FOUND, to avoid a crash. + * OpenChange/MAPIStoreFSMessage.m (-objectVersion): return 0xff...fff when "version" does not exist in the object properties. diff --git a/OpenChange/MAPIStoreFolder.m b/OpenChange/MAPIStoreFolder.m index 3e60e4ee4..e758d3eb6 100644 --- a/OpenChange/MAPIStoreFolder.m +++ b/OpenChange/MAPIStoreFolder.m @@ -641,6 +641,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe int rc = MAPISTORE_SUCCESS; NSUInteger count; NSMutableArray *oldMessageURLs; + NSString *oldMessageURL; MAPIStoreMapping *mapping; if ([sourceFolder isKindOfClass: isa] @@ -651,11 +652,17 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe mapping = [[self context] mapping]; for (count = 0; rc == MAPISTORE_SUCCESS && count < midCount; count++) { - [oldMessageURLs addObject: [mapping urlFromID: srcMids[count]]]; - rc = [self moveCopyMessageWithMID: srcMids[count] - fromFolder: sourceFolder - withMID: targetMids[count] - wantCopy: wantCopy]; + oldMessageURL = [mapping urlFromID: srcMids[count]]; + if (oldMessageURL) + { + [oldMessageURLs addObject: oldMessageURL]; + rc = [self moveCopyMessageWithMID: srcMids[count] + fromFolder: sourceFolder + withMID: targetMids[count] + wantCopy: wantCopy]; + } + else + rc = MAPISTORE_ERR_NOT_FOUND; } /* Notifications */