[Globalization] protect possible leak from value returned by vconf_get_str 50/135650/1
authorLukasz Bardeli <l.bardeli@samsung.com>
Fri, 23 Jun 2017 12:13:25 +0000 (14:13 +0200)
committerLukasz Bardeli <l.bardeli@samsung.com>
Fri, 23 Jun 2017 12:13:25 +0000 (14:13 +0200)
[Verifivation] code compiles without error.

Change-Id: I85ae0d095107750ff75bd39efb594f8af94e1b9c
Signed-off-by: Lukasz Bardeli <l.bardeli@samsung.com>
src/globalization/cordova_globalization_tools.cc

index 676c07b..27ef7b5 100644 (file)
@@ -50,6 +50,7 @@ const std::string kNumberTypeCurrency = "currency";
 Locale CordovaGlobalizationTools::GetDefaultLocale() {
   LoggerD("Entered");
   char* tempstr = vconf_get_str(VCONFKEY_REGIONFORMAT);
+  std::unique_ptr<char*> tempstr_ptr(&tempstr);
 
   if (nullptr != tempstr){
     LoggerD("Region: %s", tempstr);
@@ -59,7 +60,6 @@ Locale CordovaGlobalizationTools::GetDefaultLocale() {
 
     if (len > 0) {
       char* str_region = strndup(tempstr, len); //.UTF8 => 5
-      free(tempstr);
       Locale result = Locale::createFromName(str_region);
       free(str_region);
       return result;