Fix memory leak
[platform/core/appfw/app-core.git] / src / appcore-i18n.c
index 5cae8d7..3cbefcc 100644 (file)
@@ -82,6 +82,7 @@ void update_region(void)
 static int __set_i18n(const char *domain, const char *dir)
 {
        char *r;
+       char *lan;
 
        if (domain == NULL) {
                errno = EINVAL;
@@ -91,8 +92,12 @@ static int __set_i18n(const char *domain, const char *dir)
        r = setlocale(LC_ALL, "");
        /* if locale is not set properly, try again to set as language base */
        if (r == NULL) {
-               r = setlocale(LC_ALL, vconf_get_str(VCONFKEY_LANGSET));
-               _DBG("*****appcore setlocale=%s\n", r);
+               lan = vconf_get_str(VCONFKEY_LANGSET);
+               if (lan != NULL) {
+                       r = setlocale(LC_ALL, lan);
+                       _DBG("*****appcore setlocale=%s\n", r);
+                       free(lan);
+               }
        }
        if (r == NULL)
                _ERR("appcore: setlocale() error");