[Time] Fixed issues from prevent
authorPiotr Kosko <p.kosko@samsung.com>
Wed, 10 Jun 2015 12:22:28 +0000 (14:22 +0200)
committerPiotr Kosko <p.kosko@samsung.com>
Wed, 10 Jun 2015 12:44:08 +0000 (14:44 +0200)
[Verification] TCT passrate 100%.

Change-Id: I05d3f3e7eb610b83b75b714e13c31b31b1be7fa9
Signed-off-by: Piotr Kosko <p.kosko@samsung.com>
src/time/time_instance.cc

index ed1cf79101c56b02077832b6b578bb72ec013087..c170780de22379c1e33bc430c134efb45df9e6f4 100644 (file)
@@ -91,12 +91,18 @@ void TimeInstance::TimeGetLocalTimeZone(const JsonValue& /*args*/,
   LoggerD("Entered");
 
   UnicodeString local_timezone;
-  TimeZone::createDefault()->getID(local_timezone);
+  TimeZone* timezone = TimeZone::createDefault();
+  if (nullptr != timezone) {
+    timezone->getID(local_timezone);
+    delete timezone;
 
-  std::string localtz;
-  local_timezone.toUTF8String(localtz);
+    std::string localtz;
+    local_timezone.toUTF8String(localtz);
 
-  ReportSuccess(JsonValue(localtz), out);
+    ReportSuccess(JsonValue(localtz), out);
+  } else {
+    ReportError(out);
+  }
 }
 
 void TimeInstance::TimeGetAvailableTimeZones(const JsonValue& /*args*/,
@@ -473,7 +479,7 @@ UnicodeString TimeInstance::getDateTimeFormat(DateTimeFormatType type,
 #endif
 
     pattern = dateTimepattern->getBestPattern(
-        *(new UnicodeString(skeleton.c_str())), ec);
+        UnicodeString(skeleton.c_str()), ec);
     if (U_FAILURE(ec)) {
       LoggerE("Failed to get time pattern");
       return "";