fixed memory leak. submit/tizen_2.2/20131107.062046
authoreh1112.kim <eh1112.kim@samsung.com>
Thu, 24 Oct 2013 13:47:33 +0000 (22:47 +0900)
committereh1112.kim <eh1112.kim@samsung.com>
Thu, 24 Oct 2013 13:47:33 +0000 (22:47 +0900)
Change-Id: Id7f086ca7286b6089a27d532002b42ac08deb0c4
Signed-off-by: eh1112.kim <eh1112.kim@samsung.com>
src/FMsg_DetailedEmailMessageImpl.cpp [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 8285766..5408d9e
@@ -903,10 +903,20 @@ _DetailedEmailMessageImpl::WriteToMimeFile(const DetailedEmailMessage& message,
                        pAttachName = _StringConverter::CopyToCharArrayN(pEmailAttachmentItem->GetName());
                        SysTryCatch(NID_MSG, pAttachName != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
                        pTempAttachmentData->attachment_name = strdup(pAttachName);
+                       if (pAttachName)
+                       {
+                               delete[] pAttachName;
+                               pAttachName = null;
+                       }
 
                        pAttachFilePath = _StringConverter::CopyToCharArrayN(pEmailAttachmentItem->GetFilePath());
                        SysTryCatch(NID_MSG, pAttachFilePath != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
                        pTempAttachmentData->attachment_path = strdup(pAttachFilePath);
+                       if (pAttachFilePath)
+                       {
+                               delete[] pAttachFilePath;
+                               pAttachFilePath = null;
+                       }
 
                        pTempAttachmentData->inline_content_status = (int) pEmailAttachmentItem->GetInlineContentStatus();
                        pTempAttachmentData->drm_status = (int) pEmailAttachmentItem->GetDrmStatus();
@@ -914,6 +924,11 @@ _DetailedEmailMessageImpl::WriteToMimeFile(const DetailedEmailMessage& message,
                        pAttachMimeType = _StringConverter::CopyToCharArrayN(pEmailAttachmentItem->GetMimeType());
                        SysTryCatch(NID_MSG, pAttachMimeType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed");
                        pTempAttachmentData->attachment_mime_type = strdup(pAttachMimeType);
+                       if (pAttachMimeType)
+                       {
+                               delete[] pAttachMimeType;
+                               pAttachMimeType = null;
+                       }
 
                        pTempAttachmentData++;
                }
@@ -933,24 +948,6 @@ _DetailedEmailMessageImpl::WriteToMimeFile(const DetailedEmailMessage& message,
                pEmlFilePath = null;
        }
 
-       if (pAttachName)
-       {
-               delete[] pAttachName;
-               pAttachName = null;
-       }
-
-       if (pAttachFilePath)
-       {
-               delete[] pAttachFilePath;
-               pAttachFilePath = null;
-       }
-
-       if (pAttachMimeType)
-       {
-               delete[] pAttachMimeType;
-               pAttachMimeType = null;
-       }
-
        if (pMailData)
        {
                email_free_mail_data(&pMailData, 1);