Author: axeld Date: 2010-08-18 19:55:23 +0200 (Wed, 18 Aug 2010) New Revision: 38244 Changeset: http://dev.haiku-os.org/changeset/38244 Modified: haiku/trunk/src/kits/mail/Jamfile haiku/trunk/src/kits/mail/MailAttachment.cpp Log: * Stefano was right, there was another leak - I've fixed them all now in a nicer way. Modified: haiku/trunk/src/kits/mail/Jamfile =================================================================== --- haiku/trunk/src/kits/mail/Jamfile 2010-08-18 17:33:48 UTC (rev 38243) +++ haiku/trunk/src/kits/mail/Jamfile 2010-08-18 17:55:23 UTC (rev 38244) @@ -5,7 +5,7 @@ if $(TARGET_PLATFORM) != haiku { UsePublicHeaders mail ; } -UsePrivateHeaders mail ; +UsePrivateHeaders mail shared ; UsePublicHeaders [ FDirName add-ons mail_daemon ] ; if $(CHECK_MALLOC) { Modified: haiku/trunk/src/kits/mail/MailAttachment.cpp =================================================================== --- haiku/trunk/src/kits/mail/MailAttachment.cpp 2010-08-18 17:33:48 UTC (rev 38243) +++ haiku/trunk/src/kits/mail/MailAttachment.cpp 2010-08-18 17:55:23 UTC (rev 38244) @@ -15,6 +15,8 @@ #include <stdlib.h> #include <stdio.h> +#include <AutoDeleter.h> + class _EXPORT BSimpleMailAttachment; class _EXPORT BAttributedMailAttachment; class _EXPORT BMailAttachment; @@ -352,11 +354,13 @@ if (src == NULL) return B_NO_MEMORY; + MemoryDeleter sourceDeleter(src); + _data->Seek(0,SEEK_SET); ssize_t read = _data->Read(src,size); if (read < B_OK) - return read; // Return an error code and leak memory. + return read; // The encoded text will never be more than twice as large with any // conceivable encoding. But just in case, there's a function call which @@ -368,15 +372,15 @@ if (dest == NULL) return B_NO_MEMORY; + MemoryDeleter destinationDeleter(dest); + destSize = encode (_encoding, dest, src, read, false /* headerMode */); - if (destSize < B_OK) { - free(dest); + if (destSize < B_OK) return destSize; - } + if (destSize > 0) read = render_to->Write(dest,destSize); - free (src); - free (dest); + return (read > 0) ? B_OK : read; }