util: resource: Add missing free operation for put_resource_attr_array 13/271213/10
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 17 Feb 2022 03:11:01 +0000 (12:11 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 18 Feb 2022 07:52:00 +0000 (16:52 +0900)
Change-Id: I65f3eef225cc8601b52f99c987c70ce3209f14ea
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/util/resource.c

index cc11120..087f3c3 100644 (file)
@@ -380,6 +380,7 @@ int get_resource_attr_array(struct resource *resource, u_int64_t attr_id, struct
 int put_resource_attr_array(struct resource *resource, u_int64_t attr_id)
 {
        struct resource_attribute_value *attr_value = NULL;
+       struct array_value *array;
 
        if (!check_attr_validate(resource, attr_id, DATA_TYPE_ARRAY))
                return -EINVAL;
@@ -388,6 +389,13 @@ int put_resource_attr_array(struct resource *resource, u_int64_t attr_id)
        if (!attr_value || !attr_value->data)
                return -EINVAL;
 
+       array = (struct array_value *)attr_value->data;
+       if (array) {
+               array->type = 0;
+               array->length = 0;
+               free(array->data);
+               array->data = NULL;
+       }
        free(attr_value->data);
        attr_value->data = NULL;