From 2c7da0e1d170bdf20873c7a80eeebf78875dcaaa Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Fri, 23 Jun 2017 14:13:25 +0200 Subject: [PATCH] [Globalization] protect possible leak from value returned by vconf_get_str [Verifivation] code compiles without error. Change-Id: I85ae0d095107750ff75bd39efb594f8af94e1b9c Signed-off-by: Lukasz Bardeli --- src/globalization/cordova_globalization_tools.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globalization/cordova_globalization_tools.cc b/src/globalization/cordova_globalization_tools.cc index 676c07b..27ef7b5 100644 --- a/src/globalization/cordova_globalization_tools.cc +++ b/src/globalization/cordova_globalization_tools.cc @@ -50,6 +50,7 @@ const std::string kNumberTypeCurrency = "currency"; Locale CordovaGlobalizationTools::GetDefaultLocale() { LoggerD("Entered"); char* tempstr = vconf_get_str(VCONFKEY_REGIONFORMAT); + std::unique_ptr 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; -- 2.34.1