Fix svace static issues 47/263347/1
authorChanggyu Choi <changyu.choi@samsung.com>
Wed, 1 Sep 2021 03:17:58 +0000 (12:17 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Wed, 1 Sep 2021 03:17:58 +0000 (12:17 +0900)
Change-Id: Ie2573213d510129dc4485bcfd666e84d5a8a6799
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/lib/amd_launch.c

index 458a4bab5584a7236877f2e60120b2ffab7f3ab6..62414332c44130918eaa55e2038e926e14c2ae52 100644 (file)
@@ -2796,6 +2796,7 @@ static int __get_compinfo(struct launch_s *handle, bundle *kb, uid_t uid,
 {
        int ret;
        const char *widget_id;
+       char *buf;
        char *comp_id;
        char *tmp = NULL;
 
@@ -2810,19 +2811,24 @@ static int __get_compinfo(struct launch_s *handle, bundle *kb, uid_t uid,
                                return ret;
                } else {
                        /* widget component */
-                       comp_id = strtok_r(strdup(widget_id), "@", &tmp);
-                       if (!comp_id) {
+                       buf = strdup(widget_id);
+                       if (!buf) {
                                _E("out of memory");
                                return -1;
                        }
-
+                       comp_id = strtok_r(buf, "@", &tmp);
+                       if (!comp_id) {
+                               _E("Failed to get component id %s", widget_id);
+                               free(buf);
+                               return -1;
+                       }
                        *is_widget_component = true;
                        handle->instance_id = bundle_get_val(kb,
                                        AUL_K_WIDGET_INSTANCE_ID);
                        bundle_add_str(kb, AUL_K_COMPONENT_ID, comp_id);
                        bundle_add_str(kb, AUL_K_INSTANCE_ID,
                                        handle->instance_id);
-                       free(comp_id);
+                       free(buf);
                        handle->comp_id = bundle_get_val(kb, AUL_K_COMPONENT_ID);
                }
        }