Fix issue detected by static analysis tool 27/257827/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Sun, 25 Apr 2021 14:39:33 +0000 (23:39 +0900)
committerInHong Han <inhong1.han@samsung.com>
Tue, 4 May 2021 00:30:16 +0000 (09:30 +0900)
Pointer 'profileName' which was dereferenced at tizen_profile.cpp 42
is compared to NULL value at tizen_profile.cpp 64.

Change-Id: Ia3581ddb292eb6d0181ed51e4c88fe5b351d7dfe
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
(cherry picked from commit 8e8e3d58f37c7de1def5e9668ca1ce0c6e30513f)

ism/src/tizen_profile.cpp

index fefe46e..b3bbcfe 100644 (file)
@@ -37,8 +37,11 @@ tizen_profile_t _get_tizen_profile()
     if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
         return profile;
 
-    char *profileName;
+    char *profileName = NULL;
     system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+    if (!profileName)
+        return TIZEN_PROFILE_COMMON;
+
     switch (*profileName)
     {
         case 'm':
@@ -61,8 +64,7 @@ tizen_profile_t _get_tizen_profile()
             g_profile = TIZEN_PROFILE_COMMON;
     }
 
-    if (profileName)
-        free(profileName);
+    free(profileName);
 
     return g_profile;
 }