From eafc23d18bd1b34cc211cceb07618523244bd50f Mon Sep 17 00:00:00 2001 From: Magnus Melin Date: Tue, 1 Oct 2024 13:50:25 +0300 Subject: [PATCH] Bug 1915397 - fix resource leaks in mime_parse_stream_complete. r=BenC CID: 1137489 CID: 1137488 Differential Revision: https://phabricator.services.mozilla.com/D223678 --HG-- extra : rebase_source : 9240181f632d2e43e8e02f4e2d0541d0c20c9f99 extra : amend_source : 6637a0240f8f3400e65984bbfdf7d1070d8058e1 --- mailnews/mime/src/mimedrft.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mailnews/mime/src/mimedrft.cpp b/mailnews/mime/src/mimedrft.cpp index 2472105331..c1a3032642 100644 --- a/mailnews/mime/src/mimedrft.cpp +++ b/mailnews/mime/src/mimedrft.cpp @@ -1417,7 +1417,11 @@ static void mime_parse_stream_complete(nsMIMESession* stream) { nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), mdd->messageBody->m_tmpFile); - if (NS_FAILED(rv)) return; + if (NS_FAILED(rv)) { + delete[] newAttachData; + PR_Free(body); + return; + } inputStream->Read(body, bodyLen, &bytesRead);