From: Pawel Andruszkiewicz
Date: Mon, 8 Jun 2015 12:48:51 +0000 (+0200)
Subject: [Contact] Fixed memory leak in ContactManagerImportFromVCard.
X-Git-Tag: submit/tizen_mobile/20150612.133019^2~2^2~31^2
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bcd309560e427d95799deb194474b5fc82f3f88f;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git
[Contact] Fixed memory leak in ContactManagerImportFromVCard.
Prevent CID: 395213
[Verification] TCT pass rate 441/441.
Change-Id: I1473bc589aef86788da821add23790764e193bdf
Signed-off-by: Pawel Andruszkiewicz
---
diff --git a/src/contact/contact_manager.cc b/src/contact/contact_manager.cc
index 95452c20..4fc82098 100755
--- a/src/contact/contact_manager.cc
+++ b/src/contact/contact_manager.cc
@@ -19,9 +19,10 @@
#include
#include "common/converter.h"
-#include "common/picojson.h"
-#include "common/logger.h"
#include "common/filter-utils.h"
+#include "common/logger.h"
+#include "common/picojson.h"
+#include "common/scope_exit.h"
#include
#include
@@ -786,10 +787,13 @@ PlatformResult ContactManagerImportFromVCard(const JsonObject& args,
"Fail to convert vCard from string");
}
+ SCOPE_EXIT {
+ contacts_list_destroy(contacts_list, true);
+ };
+
int record_count = 0;
err = contacts_list_get_count(contacts_list, &record_count);
if (CONTACTS_ERROR_NONE != err || 0 == record_count) {
- contacts_list_destroy(contacts_list, true);
LoggerE("Invalid vCard string.");
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Invalid vCard string.");
}
@@ -798,7 +802,6 @@ PlatformResult ContactManagerImportFromVCard(const JsonObject& args,
contacts_list_first(contacts_list);
err = contacts_list_get_current_record_p(contacts_list, &contacts_record);
if (CONTACTS_ERROR_NONE != err || nullptr == contacts_record) {
- contacts_list_destroy(contacts_list, true);
LoggerE("Invalid vCard string.");
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Invalid vCard string.");
}