]> git.ipfire.org Git - thirdparty/grub.git/commit
commands/legacycfg: Avoid closing file twice
authorLeo Sandoval <lsandova@redhat.com>
Wed, 16 Oct 2024 17:54:38 +0000 (11:54 -0600)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 31 Oct 2024 15:08:36 +0000 (16:08 +0100)
commitf26b39860d32e2b9edb30370349e40b1ac7055c8
tree2679b2bf7f34d455a03250669e59e9d7ba3f9f4a
parent337cb248625f00fd94f80d50a4f22acc9b2f0822
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>
grub-core/commands/legacycfg.c