Fix static analysis issue
[platform/core/appfw/pkgmgr-info.git] / parser / src / pkgmgr_parser_deprecated.c
index bae8fdc..d717409 100644 (file)
@@ -402,6 +402,10 @@ static void __ps_process_mime(gpointer data, gpointer user_data)
        snprintf(ad->mime, sizeof(ad->mime), "%s", mime);
 
        appcontrol = calloc(1, sizeof(appcontrol_x));
+       if (appcontrol == NULL) {
+               _LOGD("Malloc Failed\n");
+               return;
+       }
        if (strlen(ad->operation))
                appcontrol->operation = strdup(ad->operation);
        if (strlen(ad->uri))
@@ -422,6 +426,10 @@ static void __ps_process_uri(gpointer data, gpointer user_data)
                g_list_foreach(ad->mimes, __ps_process_mime, user_data);
        } else {
                appcontrol = calloc(1, sizeof(appcontrol_x));
+               if (appcontrol == NULL) {
+                       _LOGD("Malloc Failed\n");
+                       return;
+               }
                if (strlen(ad->operation))
                        appcontrol->operation = strdup(ad->operation);
                appcontrol->uri = strdup(ad->uri);
@@ -443,6 +451,10 @@ static void __ps_process_operation(gpointer data, gpointer user_data)
                g_list_foreach(ad->mimes, __ps_process_mime, user_data);
        } else {
                appcontrol = calloc(1, sizeof(appcontrol_x));
+               if (appcontrol == NULL) {
+                       _LOGD("Malloc Failed\n");
+                       return;
+               }
                appcontrol->operation = strdup(ad->operation);
                ad->appcontrols = g_list_append(ad->appcontrols, appcontrol);
        }
@@ -1108,31 +1120,31 @@ static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
 
        for (tag = strdup(tagv[0]); tag != NULL; ) {
                ret_result = strtok_r(tag, delims, &ptr);
-
-               /*check tag :  preload */
-               if (strcmp(ret_result, "preload") == 0) {
-                       ret_result = strtok_r(NULL, delims, &ptr);
-                       if (strcmp(ret_result, "true") == 0) {
-                               free((void *)mfx->preload);
-                               mfx->preload = strdup("true");
-                       } else if (strcmp(ret_result, "false") == 0) {
-                               free((void *)mfx->preload);
-                               mfx->preload = strdup("false");
-                       }
-               /*check tag :  removable*/
-               } else if (strcmp(ret_result, "removable") == 0) {
-                       ret_result = strtok_r(NULL, delims, &ptr);
-                       if (strcmp(ret_result, "true") == 0) {
-                               free((void *)mfx->removable);
-                               mfx->removable = strdup("true");
-                       } else if (strcmp(ret_result, "false") == 0) {
-                               free((void *)mfx->removable);
-                               mfx->removable = strdup("false");
-                       }
-               /*check tag :  not matched*/
-               } else
-                       _LOGD("tag process [%s]is not defined\n", ret_result);
-
+               if (ret_result != NULL) {
+                       /*check tag :  preload */
+                       if (strcmp(ret_result, "preload") == 0) {
+                               ret_result = strtok_r(NULL, delims, &ptr);
+                               if (ret_result && strcmp(ret_result, "true") == 0) {
+                                       free((void *)mfx->preload);
+                                       mfx->preload = strdup("true");
+                               } else if (ret_result && strcmp(ret_result, "false") == 0) {
+                                       free((void *)mfx->preload);
+                                       mfx->preload = strdup("false");
+                               }
+                       /*check tag :  removable*/
+                       } else if (strcmp(ret_result, "removable") == 0) {
+                               ret_result = strtok_r(NULL, delims, &ptr);
+                               if (ret_result && strcmp(ret_result, "true") == 0) {
+                                       free((void *)mfx->removable);
+                                       mfx->removable = strdup("true");
+                               } else if (ret_result && strcmp(ret_result, "false") == 0) {
+                                       free((void *)mfx->removable);
+                                       mfx->removable = strdup("false");
+                               }
+                       /*check tag :  not matched*/
+                       } else
+                               _LOGD("tag process [%s]is not defined\n", ret_result);
+               }
                free(tag);
 
                /*check next value*/