* Stefano was right, there was another leak - I've fixed them all now in a

nicer way.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38244 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-08-18 17:55:23 +00:00
parent e1a6422727
commit 02b5d2e4e3
2 changed files with 11 additions and 7 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
if $(TARGET_PLATFORM) != haiku {
UsePublicHeaders mail ;
}
UsePrivateHeaders mail ;
UsePrivateHeaders mail shared ;
UsePublicHeaders [ FDirName add-ons mail_daemon ] ;
if $(CHECK_MALLOC) {
+10 -6
View File
@@ -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 @@ status_t BSimpleMailAttachment::RenderToRFC822(BPositionIO *render_to) {
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 @@ status_t BSimpleMailAttachment::RenderToRFC822(BPositionIO *render_to) {
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;
}