Fix invalid memory access 08/60208/1
authorsung.goo.kim <sung.goo.kim@samsung.com>
Wed, 24 Feb 2016 06:45:12 +0000 (15:45 +0900)
committersung.goo.kim <sung.goo.kim@samsung.com>
Wed, 24 Feb 2016 06:45:12 +0000 (15:45 +0900)
Change-Id: I919a78b40a731a19572a0093c3b635f69221a800

lib/icl-resource-interfaces.c
lib/icl-resource-types.c

index 1b2c262..a46721d 100644 (file)
@@ -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;
 }
index c288782..0078cde 100644 (file)
@@ -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;
 }