Fix a Coverity warning about resource leak:
CID 465889: (#4 of 4): Resource leak (RESOURCE_LEAK)
32. leaked_storage: Variable fullpath going out of scope leaks the
storage it points to.
Fix it by releasing the 'fullpath', when file name does not matches
'*.conf' code path(s).
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
/* we are interested in .conf files, skip others */
file_ext = strstr(item->d_name, ".conf");
- if (!file_ext)
+ if (!file_ext) {
+ free(fullpath);
continue;
+ }
- if (strcmp(file_ext, ".conf") || strlen(item->d_name) == 5)
+ if (strcmp(file_ext, ".conf") || strlen(item->d_name) == 5) {
+ free(fullpath);
continue;
+ }
ret = cgroup_string_list_add_item(list, fullpath);
count++;