[Non-ACR][Resolving crash issue due to NULL string(DF180706-00508)] 27/183727/3 accepted/tizen/unified/20180712.142227 submit/tizen/20180711.045147
authorAbhishek Vijay <abhishek.v@samsung.com>
Tue, 10 Jul 2018 11:02:16 +0000 (16:32 +0530)
committerAbhishek Vijay <abhishek.v@samsung.com>
Tue, 10 Jul 2018 11:48:15 +0000 (17:18 +0530)
Change-Id: Ide783b7eff5ade1ebcbd42172c3b961d6c2a0a75
Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
src/account.c

index b488ea5..04d8f1b 100644 (file)
@@ -355,7 +355,7 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id)
                                                _SECURE_D("Attribute: xml:lang - %s", xml_lang);
 
                                                char* lang = (char*)xml_lang;
-                                               char* converted_lang = NULL;
+                                               gchar* converted_lang = NULL;
 
                                                gchar** tokens = g_strsplit(lang, "-", 2);
                                                if (tokens == NULL) {
@@ -364,16 +364,29 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id)
                                                        goto CATCH;
                                                }
 
-                                               char* upper_token = g_ascii_strup(tokens[1], strlen(tokens[1]));
-                                               if (upper_token == NULL) {
-                                                       ret = -1;
-                                                       g_strfreev(tokens);
-                                                       _E("Failed to convert to upper case.");
+                                               gchar *upper_token = NULL;
+                                               if (tokens[1] != NULL) {
+                                                       upper_token = g_ascii_strup(tokens[1], strlen(tokens[1]));
+                                                       if (upper_token == NULL) {
+                                                               ret = -1;
+                                                               g_strfreev(tokens);
+                                                               _E("Failed to convert to upper case.");
+                                                               goto CATCH;
+                                                       }
+                                               } else {
+                                                       _E("upper-token string is not available");
                                                        goto CATCH;
                                                }
 
-                                               converted_lang = g_strdup_printf("%s_%s", tokens[0], upper_token);
-                                               free(upper_token);
+                                               if (tokens[0] != NULL) {
+                                                       converted_lang = g_strdup_printf("%s_%s", tokens[0], upper_token);
+                                                       g_free(upper_token);
+                                               } else {
+                                                       _E("token string not available");
+                                                       g_free(upper_token);
+                                                       g_strfreev(tokens);
+                                                       goto CATCH;
+                                               }
 
                                                if (converted_lang == NULL) {
                                                        ret = -1;