Fix exception handling 05/136405/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 29 Jun 2017 09:44:27 +0000 (18:44 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 29 Jun 2017 09:44:27 +0000 (18:44 +0900)
If the return value of the appsvc API is NULL pointer, the getter API
should not return a negative error value.

Change-Id: I1069186e3f11cd4010f87991f371a43eaabf2412
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
app_control/app_control.c

index d2ad6a0..55eda27 100755 (executable)
@@ -342,12 +342,13 @@ int app_control_get_operation(app_control_h app_control, char **operation)
                return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
        operation_value = aul_svc_get_operation(app_control->data);
-       if (operation_value == NULL)
-               return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
-
-       *operation = strdup(operation_value);
-       if (*operation == NULL)
-               return app_control_error(APP_CONTROL_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       if (operation_value) {
+               *operation = strdup(operation_value);
+               if (*operation == NULL)
+                       return app_control_error(APP_CONTROL_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       } else {
+               *operation = NULL;
+       }
 
        return APP_CONTROL_ERROR_NONE;
 }
@@ -375,12 +376,13 @@ int app_control_get_uri(app_control_h app_control, char **uri)
                return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
        uri_value = aul_svc_get_uri(app_control->data);
-       if (uri_value == NULL)
-               return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
-
-       *uri = strdup(uri_value);
-       if (*uri == NULL)
-               return app_control_error(APP_CONTROL_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       if (uri_value) {
+               *uri = strdup(uri_value);
+               if (*uri == NULL)
+                       return app_control_error(APP_CONTROL_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       } else {
+               *uri = NULL;
+       }
 
        return APP_CONTROL_ERROR_NONE;
 }
@@ -408,12 +410,13 @@ int app_control_get_mime(app_control_h app_control, char **mime)
                return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
        mime_value = aul_svc_get_mime(app_control->data);
-       if (mime_value == NULL)
-               return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
-
-       *mime = strdup(mime_value);
-       if (*mime == NULL)
-               return app_control_error(APP_CONTROL_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       if (mime_value) {
+               *mime = strdup(mime_value);
+               if (*mime == NULL)
+                       return app_control_error(APP_CONTROL_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       } else {
+               *mime = NULL;
+       }
 
        return APP_CONTROL_ERROR_NONE;
 }
@@ -441,12 +444,13 @@ int app_control_get_category(app_control_h app_control, char **category)
                return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
        category_value = aul_svc_get_category(app_control->data);
-       if (category_value == NULL)
-               return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
-
-       *category = strdup(category_value);
-       if (*category == NULL)
-               return app_control_error(APP_CONTROL_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       if (category_value) {
+               *category = strdup(category_value);
+               if (*category == NULL)
+                       return app_control_error(APP_CONTROL_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       } else {
+               *category = NULL;
+       }
 
        return APP_CONTROL_ERROR_NONE;
 }
@@ -486,12 +490,13 @@ int app_control_get_app_id(app_control_h app_control, char **app_id)
                return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
        app_id_value = aul_svc_get_appid(app_control->data);
-       if (app_id_value == NULL)
-               return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
-
-       *app_id = strdup(app_id_value);
-       if (*app_id == NULL)
-               return app_control_error(APP_CONTROL_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       if (app_id_value) {
+               *app_id = strdup(app_id_value);
+               if (*app_id == NULL)
+                       return app_control_error(APP_CONTROL_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       } else {
+               *app_id = NULL;
+       }
 
        return APP_CONTROL_ERROR_NONE;
 }