diff options
author | Jung Jihoon <jh8801.jung@samsung.com> | 2019-08-19 20:10:06 +0900 |
---|---|---|
committer | Jung Jihoon <jh8801.jung@samsung.com> | 2019-08-20 13:47:26 +0900 |
commit | fe06b4eeb2ac648f91bd8882ac1fadb51d798098 (patch) | |
tree | 5c7b8791676178e3f632e267c5bb5dcd4ddb688e | |
parent | b283cce380cd529b9b51ce671a735fa23cc94211 (diff) | |
download | mdg-manager-accepted/tizen_6.5_unified.tar.gz mdg-manager-accepted/tizen_6.5_unified.tar.bz2 mdg-manager-accepted/tizen_6.5_unified.zip |
Fix Svace & coverty issuestizen_6.5.m2_releasetizen_6.0.m2_releasetizen_5.5.m2_releasesubmit/tizen_6.5/20211028.162201submit/tizen_6.0_hotfix/20201103.114803submit/tizen_6.0_hotfix/20201102.192503submit/tizen_6.0/20201029.205103submit/tizen_5.5_wearable_hotfix/20201026.184303submit/tizen_5.5_mobile_hotfix/20201026.185103submit/tizen_5.5/20191031.000003submit/tizen/20190820.045040accepted/tizen/unified/20190820.115003accepted/tizen/6.5/unified/20211028.100312accepted/tizen/6.0/unified/hotfix/20201103.050246accepted/tizen/6.0/unified/20201030.120413accepted/tizen/5.5/unified/wearable/hotfix/20201027.114914accepted/tizen/5.5/unified/mobile/hotfix/20201027.083940accepted/tizen/5.5/unified/20191031.024023tizen_6.5tizen_6.0_hotfixtizen_6.0tizen_5.5_wearable_hotfixtizen_5.5_tvtizen_5.5_mobile_hotfixtizen_5.5accepted/tizen_6.5_unifiedaccepted/tizen_6.0_unified_hotfixaccepted/tizen_6.0_unifiedaccepted/tizen_5.5_unified_wearable_hotfixaccepted/tizen_5.5_unified_mobile_hotfixaccepted/tizen_5.5_unified
- Svace : 317229, 372690 DEREF_OF_NULL
- Coverity : 1043621, 1043616, 1043593, 1043590 Reasource leak
Change-Id: I1a48df4605fb8d48d74e40eb4f4e47ff711ffec1
Signed-off-by: Jung Jihoon <jh8801.jung@samsung.com>
-rwxr-xr-x | src/mdg-manager/src/mdgd_iot.cpp | 78 | ||||
-rw-r--r-- | src/mdg-manager/src/mdgd_iot_server.cpp | 4 |
2 files changed, 56 insertions, 26 deletions
diff --git a/src/mdg-manager/src/mdgd_iot.cpp b/src/mdg-manager/src/mdgd_iot.cpp index 8120b24..d0c170d 100755 --- a/src/mdg-manager/src/mdgd_iot.cpp +++ b/src/mdg-manager/src/mdgd_iot.cpp @@ -826,33 +826,49 @@ int mdgd_iot_initialize() OicUuid_t *uuid = &iter->doxm->deviceID; mdgd_uuid_to_str(uuid, &device_id); - if (g_strcmp0(mdgd_ctx->device_uuid, device_id) != 0) { - iter = iter->next; - continue; + if (g_strcmp0(mdgd_ctx->device_uuid, device_id) == 0) { + char *device_name = NULL; + char *model_name = NULL; + char *platform_ver = NULL; + char *profile = NULL; + + mdgd_device_t *device = (mdgd_device_t *)g_try_malloc0(sizeof(mdgd_device_t)); + if (device == NULL) { + LOG_ERR("device is NULL"); + if (device_id != NULL) + free(device_id); + + break; + } + + system_settings_get_value_string(SYSTEM_SETTINGS_KEY_DEVICE_NAME, &device_name); + system_info_get_platform_string(SYSTEM_INFO_MODEL_NAME, &model_name); + system_info_get_platform_string(SYSTEM_INFO_PLATFORM_VERSION, &platform_ver); + system_info_get_platform_string(SYSTEM_INFO_PROFILE, &profile); + + device->device_id = device_id; + device->device_name = g_strdup(device_name); + device->model_name = g_strdup(model_name); + device->platform_ver = g_strdup(platform_ver); + device->profile = g_strdup(profile); + device->vendor_id = g_strdup("6FFF"); + device->is_invited = true; + device->type = MDGD_DEVICE_TYPE_LOCAL; + + mdgd_ctx->device = device; + LOG_DEBUG("local device stored"); + + g_free(device_name); + g_free(model_name); + g_free(platform_ver); + g_free(profile); + + break; } - mdgd_device_t *device = (mdgd_device_t *)g_try_malloc0(sizeof(mdgd_device_t)); - char *device_name = NULL; - char *model_name = NULL; - char *platform_ver = NULL; - char *profile = NULL; - - system_settings_get_value_string(SYSTEM_SETTINGS_KEY_DEVICE_NAME, &device_name); - system_info_get_platform_string(SYSTEM_INFO_MODEL_NAME, &model_name); - system_info_get_platform_string(SYSTEM_INFO_PLATFORM_VERSION, &platform_ver); - system_info_get_platform_string(SYSTEM_INFO_PROFILE, &profile); - - device->device_id = device_id; - device->device_name = g_strdup(device_name); - device->model_name = g_strdup(model_name); - device->platform_ver = g_strdup(platform_ver); - device->profile = g_strdup(profile); - device->vendor_id = g_strdup("6FFF"); - device->is_invited = true; - device->type = MDGD_DEVICE_TYPE_LOCAL; - - mdgd_ctx->device = device; - LOG_DEBUG("local device stored"); + if (device_id != NULL) + free(device_id); + iter = iter->next; } @@ -863,7 +879,17 @@ int mdgd_iot_deinitialize() { LOG_BEGIN(); - //iot deinitiatlize + mdgd_context_t *mdgd_ctx = mdgd_context_get_context(); + + if (mdgd_ctx->device_uuid != NULL) { + free(mdgd_ctx->device_uuid); + mdgd_ctx->device_uuid = NULL; + } + + if (mdgd_ctx->device != NULL) { + mdgd_clean_device(mdgd_ctx->device); + mdgd_ctx->device = NULL; + } LOG_END(); diff --git a/src/mdg-manager/src/mdgd_iot_server.cpp b/src/mdg-manager/src/mdgd_iot_server.cpp index c7b4efe..43ac34e 100644 --- a/src/mdg-manager/src/mdgd_iot_server.cpp +++ b/src/mdg-manager/src/mdgd_iot_server.cpp @@ -353,6 +353,10 @@ OCEntityHandlerResult _request_handler(std::shared_ptr<OCResourceRequest> reques if (sender != NULL) { mdgd_channel_t *channel = (mdgd_channel_t *)g_try_malloc0(sizeof(mdgd_channel_t)); + if (channel == NULL) { + LOG_ERR("channel is NULL"); + break; + } channel->device_id = g_strdup(requester_id.c_str()); channel->channel_id = g_strdup(channel_id.c_str()); channel->remote_address = g_strdup("TEMP"); |