diff --git a/ChangeLog b/ChangeLog index 5056fc01e..bbb1efd6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-10-17 Wolfgang Sourdeau + + * OpenChange/MAPIStoreMapping.m (-initForUsername:withIndexing:): + attach the struct tdb_wrap *indexing to a new memCtx ivar, in + order to make sure its value is retained until the release of the + mapping instance. + 2011-10-14 Wolfgang Sourdeau * OpenChange/MAPIStoreGCSMessageTable.m diff --git a/OpenChange/MAPIStoreMapping.h b/OpenChange/MAPIStoreMapping.h index a6de24880..484c74da3 100644 --- a/OpenChange/MAPIStoreMapping.h +++ b/OpenChange/MAPIStoreMapping.h @@ -30,6 +30,7 @@ @interface MAPIStoreMapping : NSObject { + void *memCtx; NSString *username; struct tdb_wrap *indexing; NSMutableDictionary *mapping; /* FID/MID -> url */ diff --git a/OpenChange/MAPIStoreMapping.m b/OpenChange/MAPIStoreMapping.m index e38efc69b..c1a4b1f6b 100644 --- a/OpenChange/MAPIStoreMapping.m +++ b/OpenChange/MAPIStoreMapping.m @@ -112,6 +112,7 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2, { if ((self = [super init])) { + memCtx = talloc_zero (NULL, TALLOC_CTX); mapping = [NSMutableDictionary new]; reverseMapping = [NSMutableDictionary new]; indexing = NULL; @@ -153,6 +154,7 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2, { ASSIGN (username, newUsername); indexing = newIndexing; + (void) talloc_reference (memCtx, newIndexing); tdb_traverse_read (indexing->tdb, MAPIStoreMappingTDBTraverse, mapping); keys = [mapping allKeys]; max = [keys count]; @@ -175,6 +177,7 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2, [username release]; [mapping release]; [reverseMapping release]; + talloc_free (memCtx); [super dealloc]; }