binutils: fix resource leak on aa-load

Dir "d" is not closed when asprintf fails.

Found by coverity: CID 321416:  Resource leaks  (RESOURCE_LEAK)

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
This commit is contained in:
Georgia Garcia 2023-06-30 10:00:29 -03:00
parent ab218526bf
commit b0902a34d1

View file

@ -179,6 +179,7 @@ static int load_policy_dir(const char *dir_path)
} }
if (asprintf(&file, "%s/%s", dir_path, dir->d_name) == -1) { if (asprintf(&file, "%s/%s", dir_path, dir->d_name) == -1) {
error("Failure allocating memory"); error("Failure allocating memory");
closedir(d);
return -1; return -1;
} }
load_policy_file(file); load_policy_file(file);