Fix memory leak in app control 37/177637/2 accepted/tizen/unified/20180503.080721 submit/tizen/20180502.103655
authorlokilee73 <changjoo.lee@samsung.com>
Wed, 2 May 2018 09:25:00 +0000 (18:25 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Wed, 2 May 2018 09:27:20 +0000 (18:27 +0900)
Change-Id: I5c08fc89481759b3f1318e657ff6f47b47a82cb4
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
src/mmc/mmc-mobile.c
src/usb/usbotg-mobile.c

index 27e1686dbc3fbd2486b104da3916ebe11f6744f1..dece29993eac21135e4b37bef344cd38d862bab4 100755 (executable)
@@ -128,7 +128,7 @@ static void send_mount_signal(char *signal)
 static void launch_app(int type)
 {
        app_control_h app_control = NULL;
-       int ret;
+       int ret = -1;
 
        ret = app_control_create(&app_control);
        if (ret != APP_CONTROL_ERROR_NONE)
@@ -146,19 +146,23 @@ static void launch_app(int type)
                ret = app_control_set_app_id(app_control, ODE_APPNAME);
        } else {
                _E("No matched type(%d)", type);
-               return;
+               goto out;
        }
 
        if (ret != APP_CONTROL_ERROR_NONE) {
-               (void)app_control_destroy(app_control);
-               return;
+               _E("Fail to set app id");
+               goto out;
        }
 
        ret = app_control_send_launch_request(app_control, NULL, NULL);
        if (ret != APP_CONTROL_ERROR_NONE)
-               _E("Failed to send launch request");
+               _E("Fail to send launch request");
 
-       (void)app_control_destroy(app_control);
+out:
+       if (app_control) {
+               (void)app_control_destroy(app_control);
+               app_control = NULL;
+       }
 }
 
 static void send_general_mount_signal(const struct popup_ops *ops)
index d83bba52d22de940809149d5290262ce22812938..abc760752ed19f8f60a726c2db75806cf38b4ba4 100755 (executable)
@@ -107,7 +107,7 @@ static void launch_app(int type)
 {
        app_control_h app_control;
 
-       int ret, i, type_len;
+       int ret = -1, i, type_len;
 
        type_len = ARRAY_SIZE(app_type);
        for (i = 0 ; i < ARRAY_SIZE(app_type) ; i++) {
@@ -129,19 +129,23 @@ static void launch_app(int type)
                ret = app_control_set_app_id(app_control, GALLERY_APPNAME);
        else {
                _E("No matched type(%d)", type);
-               return;
+               goto out;
        }
 
        if (ret != APP_CONTROL_ERROR_NONE) {
-               (void)app_control_destroy(app_control);
-               return;
+               _E("Fail to set app id");
+               goto out;
        }
 
        ret = app_control_send_launch_request(app_control, NULL, NULL);
        if (ret != APP_CONTROL_ERROR_NONE)
-               _E("Failed to send launch request");
+               _E("Fail to send launch request");
 
-       (void)app_control_destroy(app_control);
+out:
+       if (app_control) {
+               (void)app_control_destroy(app_control);
+               app_control = NULL;
+       }
 }
 
 static void storage_browse(const struct popup_ops *ops)