From 32aba70938272dc57f050da5b48f25531b02eaed Mon Sep 17 00:00:00 2001 From: "sung.goo.kim" Date: Wed, 24 Feb 2016 15:45:12 +0900 Subject: [PATCH] Fix invalid memory access Change-Id: I919a78b40a731a19572a0093c3b635f69221a800 --- lib/icl-resource-interfaces.c | 4 +++- lib/icl-resource-types.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/icl-resource-interfaces.c b/lib/icl-resource-interfaces.c index 1b2c262..a46721d 100644 --- a/lib/icl-resource-interfaces.c +++ b/lib/icl-resource-interfaces.c @@ -124,6 +124,7 @@ API int iotcon_resource_interfaces_remove(iotcon_resource_interfaces_h ifaces, const char *iface) { GList *node; + char *node_data; RETV_IF(false == ic_utils_check_oic_feature_supported(), IOTCON_ERROR_NOT_SUPPORTED); RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER); @@ -137,8 +138,9 @@ API int iotcon_resource_interfaces_remove(iotcon_resource_interfaces_h ifaces, return IOTCON_ERROR_NO_DATA; } + node_data = node->data; ifaces->iface_list = g_list_delete_link(ifaces->iface_list, node); - free(node->data); + free(node_data); return IOTCON_ERROR_NONE; } diff --git a/lib/icl-resource-types.c b/lib/icl-resource-types.c index c288782..0078cde 100644 --- a/lib/icl-resource-types.c +++ b/lib/icl-resource-types.c @@ -128,6 +128,7 @@ API int iotcon_resource_types_add(iotcon_resource_types_h types, const char *typ API int iotcon_resource_types_remove(iotcon_resource_types_h types, const char *type) { GList *found_node; + char *node_data; RETV_IF(false == ic_utils_check_oic_feature_supported(), IOTCON_ERROR_NOT_SUPPORTED); RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER); @@ -141,8 +142,9 @@ API int iotcon_resource_types_remove(iotcon_resource_types_h types, const char * return IOTCON_ERROR_NO_DATA; } + node_data = found_node->data; types->type_list = g_list_delete_link(types->type_list, found_node); - free(found_node->data); + free(node_data); return IOTCON_ERROR_NONE; } -- 2.34.1