mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-21 06:49:35 +00:00
commands/legacycfg: Avoid closing file twice
An internal (at Red Hat) static soure code scan detected an
use-after-free scenario:
Error: USE_AFTER_FREE (CWE-416):
grub-2.06/grub-core/commands/legacycfg.c:194: freed_arg: "grub_file_close" frees "file".
grub-2.06/grub-core/commands/legacycfg.c:201: deref_arg: Calling "grub_file_close" dereferences freed pointer "file".
# 199| if (!args)
# 200| {
# 201|-> grub_file_close (file);
# 202| grub_free (suffix);
# 203| grub_free (entrysrc);
So, remove the extra file close call.
Signed-off-by: Leo Sandoval <lsandova@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
337cb24862
commit
f26b39860d
1 file changed
-1
@@ -198,7 +198,6 @@ legacy_file (const char *filename)
|
|||||||
const char **args = grub_malloc (sizeof (args[0]));
|
const char **args = grub_malloc (sizeof (args[0]));
|
||||||
if (!args)
|
if (!args)
|
||||||
{
|
{
|
||||||
grub_file_close (file);
|
|
||||||
grub_free (suffix);
|
grub_free (suffix);
|
||||||
grub_free (entrysrc);
|
grub_free (entrysrc);
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|||||||
Reference in new issue
Block a user