]> git.ipfire.org Git - thirdparty/grub.git/commit
affs: Fix memory leaks
authorDarren Kenny <darren.kenny@oracle.com>
Thu, 26 Nov 2020 12:48:07 +0000 (12:48 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 2 Mar 2021 14:54:16 +0000 (15:54 +0100)
commit178ac5107389f8e5b32489d743d6824a5ebf342a
tree4862b790f1fd7eade912bff645d0df4c5e59d31e
parent7aab03418ec6a9b991aa44416cb2585aff4e7972
affs: Fix memory leaks

The node structure reference is being allocated but not freed if it
reaches the end of the function. If any of the hooks had returned
a non-zero value, then node would have been copied in to the context
reference, but otherwise node is not stored and should be freed.

Similarly, the call to grub_affs_create_node() replaces the allocated
memory in node with a newly allocated structure, leaking the existing
memory pointed by node.

Finally, when dir->parent is set, then we again replace node with newly
allocated memory, which seems unnecessary when we copy in the values
from dir->parent immediately after.

Fixes: CID 73759
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/fs/affs.c