Add NULL check for config free function 17/116617/1
authorJeongmo Yang <jm80.yang@samsung.com>
Mon, 27 Feb 2017 08:47:27 +0000 (17:47 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 27 Feb 2017 08:47:27 +0000 (17:47 +0900)
[Version] 0.1.53
[Profile] Common
[Issue Type] Bug fix
[Dependency module] N/A

Change-Id: I54e1df68baffc6f6ebf098e762aaf283c2401e96
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/mused.spec
src/muse_core_config.c

index 68d160d..538b97a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mused
 Summary:    A Multimedia Daemon in Tizen Native API
-Version:    0.1.52
+Version:    0.1.53
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index ef82c45..9351d81 100644 (file)
@@ -230,19 +230,25 @@ static void _muse_core_config_free(void)
        if (g_muse_core_conf->muse_dict)
                iniparser_freedict(g_muse_core_conf->muse_dict);
 
-       host = strtok_r(g_muse_core_conf->hosts, COMMA, &ptr);
-       g_muse_core_conf->host_cnt = 0;
+       if (g_muse_core_conf->hosts) {
+               host = strtok_r(g_muse_core_conf->hosts, COMMA, &ptr);
+               g_muse_core_conf->host_cnt = 0;
+
+               while (host) {
+                       LOGD("host: %s", host);
+                       MUSE_FREE(g_muse_core_conf->host_infos[g_muse_core_conf->host_cnt]->path);
+                       MUSE_FREE(g_muse_core_conf->host_infos[g_muse_core_conf->host_cnt]->preloaded);
+                       MUSE_FREE(g_muse_core_conf->host_infos[g_muse_core_conf->host_cnt]);
+                       host = strtok_r(NULL, COMMA, &ptr);
+                       g_muse_core_conf->host_cnt++;
+               }
 
-       while (host) {
-               LOGD("host: %s", host);
-               MUSE_FREE(g_muse_core_conf->host_infos[g_muse_core_conf->host_cnt]->path);
-               MUSE_FREE(g_muse_core_conf->host_infos[g_muse_core_conf->host_cnt]->preloaded);
-               MUSE_FREE(g_muse_core_conf->host_infos[g_muse_core_conf->host_cnt]);
-               host = strtok_r(NULL, COMMA, &ptr);
-               g_muse_core_conf->host_cnt++;
+               free(g_muse_core_conf->hosts);
+               g_muse_core_conf->hosts = NULL;
+       } else {
+               LOGE("NULL hosts");
        }
 
-       MUSE_FREE(g_muse_core_conf->hosts);
        for (i = 0; i <= g_muse_core_conf->host_cnt; i++)
                MUSE_FREE(g_muse_core_conf->host[i]);