Fix Svace Issue 32/100932/1 accepted/tizen/mobile/20161130.232558 submit/tizen/20161130.053756
authorJooseok Song <seogii.song@samsung.com>
Wed, 30 Nov 2016 01:00:57 +0000 (10:00 +0900)
committerJooseok Song <seogii.song@samsung.com>
Wed, 30 Nov 2016 01:00:57 +0000 (10:00 +0900)
Change-Id: Id75e6e6026180133891a7b8ece1bcf704676529a
Signed-off-by: Jooseok Song <seogii.song@samsung.com>
inc/ad-id.h
src/ad-id.c

index 88925dc..a3e6355 100644 (file)
@@ -64,6 +64,13 @@ typedef struct appdata {
                } \
        } while (0)
 
+#define SAFE_FREE_CUSTOM(X, Y)                 if (NULL != (X))                                \
+                                               {                                               \
+                                                       Y((X));                                 \
+                                                       (X) = NULL;                             \
+                                               }
+#define SAFE_FREE(X)                           SAFE_FREE_CUSTOM(X, free)
+
 #ifdef __cplusplus
 }
 #endif /*__cplusplus */
index f97526a..004a929 100644 (file)
@@ -36,8 +36,10 @@ const char *get_res_path()
        static char res_folder_path[PATH_MAX] = {'\0'};
        if (res_folder_path[0] == '\0') {
                char *resource_path_buf = app_get_resource_path();
+               if (NULL != resource_path_buf) {
                strncpy(res_folder_path, resource_path_buf, PATH_MAX-1);
-               free(resource_path_buf);
+               }
+               SAFE_FREE(resource_path_buf);
        }
        return res_folder_path;
 }
@@ -430,10 +432,11 @@ static void _app_control_cb(app_control_h app_control, void *user_data)
 
        if (value != NULL && !strcmp(value, "GenerateAdId")) {
                char *adid = vconf_get_str(VCONFKEY_SETAPPL_AD_ID);
-               if (!strcmp(adid, DEFAULT_ID)) {
+               if ((NULL != adid) && (!strcmp(adid, DEFAULT_ID))) {
                        make_ad_id();
                        vconf_set_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, 0);
                }
+               SAFE_FREE(adid);
        } else {
                create_base_gui(ad);
        }