From 02de38b077d3532e6f12428ecc3268fbce222b9a Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 25 Sep 2008 13:12:19 +0000 Subject: [PATCH] Fixed leaks. CID 893 and 894. There are still some leaks in this file, but the code is too complex and I won't touch it. I'd feel better if someone who knows it better would have a look git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27739 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mail/Content.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/apps/mail/Content.cpp b/src/apps/mail/Content.cpp index 9271f184eb..28ac7fac1e 100644 --- a/src/apps/mail/Content.cpp +++ b/src/apps/mail/Content.cpp @@ -1216,6 +1216,7 @@ TTextView::MessageReceived(BMessage *msg) } if (file.Read(text, size) < B_OK) { puts("could not read from file"); + free(text); continue; } if (!inserted) { @@ -2515,8 +2516,7 @@ TTextView::Reader::Run(void *_this) header = eol; } - if (buffer) - free(buffer); + free(buffer); reader->Process("\r\n", 2, true); } else if (!reader->Process(msg, len, true)) @@ -2597,8 +2597,7 @@ done: reader->Unlock(); delete reader; - if (msg) - free(msg); + free(msg); return B_NO_ERROR; } @@ -3120,9 +3119,11 @@ TTextView::AddQuote(int32 start, int32 finish) int32 lineLength = index - lastLine + 1; target = (char *)realloc(target, targetLength + lineLength + quoteLength); - if (target == NULL) + if (target == NULL) { // free the old buffer? + free(text); return; + } // copy the quote sign memcpy(&target[targetLength], QUOTE, quoteLength);