From f4e15e2db8fdda0ff6d94d1690e35ebab1d334a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20J=2E=20Hern=C3=A1ndez=20Blasco?= Date: Wed, 26 Nov 2014 09:20:45 +0100 Subject: [PATCH] Fix memory leak on getPidTagSubject Valgrind crafted report: =40967== 128,927 (53,750 direct, 75,177 indirect) bytes in 383 blocks are definitely lost in loss record 10,104 of 10,179 ==40967== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==40967== by 0x86EDE3D: talloc_strndup (talloc.c:613) ==40967== by 0x34D2BB9E: _i_NSString_MAPIStoreDataTypes_asUnicodeInMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend) ==40967== by 0x34D2025B: _i_MAPIStoreMailMessage__getPidTagNormalizedSubject_inMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend) ==40967== by 0x34CFCD40: _i_MAPIStoreObject__getProperty_withTag_inMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend) ==40967== by 0x34CFBE21: _i_MAPIStoreMessage__getPidTagSubject_inMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend) ==40967== by 0x34CFBEB6: _i_MAPIStoreMessage__getPidTagOriginalSubject_inMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend) ==40967== by 0x34CFCD40: _i_MAPIStoreObject__getProperty_withTag_inMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend) ==40967== by 0x34CFD07E: _i_MAPIStoreObject__getProperties_withTags_andCount_inMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend) --- OpenChange/MAPIStoreMessage.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenChange/MAPIStoreMessage.m b/OpenChange/MAPIStoreMessage.m index 444ecd0fb..fc20dd0d0 100644 --- a/OpenChange/MAPIStoreMessage.m +++ b/OpenChange/MAPIStoreMessage.m @@ -795,7 +795,7 @@ rtf2html (NSData *compressedRTF) TALLOC_CTX *localMemCtx; char *prefix, *normalizedSubject; - localMemCtx = talloc_zero (NULL, TALLOC_CTX); + localMemCtx = talloc_zero (memCtx, TALLOC_CTX); if ([self getProperty: (void **) &prefix withTag: PidTagSubjectPrefix inMemCtx: localMemCtx] @@ -807,6 +807,8 @@ rtf2html (NSData *compressedRTF) if (rc == MAPISTORE_SUCCESS) *data = talloc_asprintf (memCtx, "%s%s", prefix, normalizedSubject); + talloc_free(localMemCtx); + return rc; }