summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJung Jihoon <jh8801.jung@samsung.com>2019-08-19 20:10:06 +0900
committerJung Jihoon <jh8801.jung@samsung.com>2019-08-20 13:47:26 +0900
commitfe06b4eeb2ac648f91bd8882ac1fadb51d798098 (patch)
tree5c7b8791676178e3f632e267c5bb5dcd4ddb688e
parentb283cce380cd529b9b51ce671a735fa23cc94211 (diff)
downloadmdg-manager-accepted/tizen_5.5_unified.tar.gz
mdg-manager-accepted/tizen_5.5_unified.tar.bz2
mdg-manager-accepted/tizen_5.5_unified.zip
- 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-xsrc/mdg-manager/src/mdgd_iot.cpp78
-rw-r--r--src/mdg-manager/src/mdgd_iot_server.cpp4
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");