Fix to get locale language and country data
[platform/core/api/system-settings.git] / src / system_setting_platform.c
index aded30a..ddbb45b 100644 (file)
@@ -1374,9 +1374,15 @@ int system_setting_get_locale_country(system_settings_key_e key, void **value)
 
        /* parsing validation */
        /* en_US.UTF-8 */
-       char arr[20];
+       char arr[21] = {0,};
        snprintf(arr, 20, "%s", vconf_value);
-       arr[5] = '\0';
+       for (int i = 0; i < strlen(arr); i++) {
+               if ('.' == arr[i]) {
+                       arr[i] = 0;
+                       SETTING_TRACE("replace . to NULL : %d", i);
+                       break;
+               }
+       }
        *value = strdup(arr);
        free(vconf_value);
        vconf_value = NULL;
@@ -1427,9 +1433,15 @@ int system_setting_get_locale_language(system_settings_key_e key, void **value)
 
        /* parsing validation */
        /* en_US.UTF-8 */
-       char arr[20];
+       char arr[21] = {0,};
        snprintf(arr, 20, "%s", vconf_value);
-       arr[5] = '\0';
+       for (int i = 0; i < strlen(arr); i++) {
+               if ('.' == arr[i]) {
+                       arr[i] = 0;
+                       SETTING_TRACE("replace . to NULL : %d", i);
+                       break;
+               }
+       }
        *value = strdup(arr);
        free(vconf_value);
        vconf_value = NULL;