nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone
b1bcb2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b1bcb2
From: Darren Kenny <darren.kenny@oracle.com>
b1bcb2
Date: Thu, 26 Nov 2020 15:31:53 +0000
b1bcb2
Subject: [PATCH] syslinux: Fix memory leak while parsing
b1bcb2
b1bcb2
In syslinux_parse_real() the 2 points where return is being called
b1bcb2
didn't release the memory stored in buf which is no longer required.
b1bcb2
b1bcb2
Fixes: CID 176634
b1bcb2
b1bcb2
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
b1bcb2
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
b1bcb2
---
b1bcb2
 grub-core/lib/syslinux_parse.c | 6 +++++-
b1bcb2
 1 file changed, 5 insertions(+), 1 deletion(-)
b1bcb2
b1bcb2
diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c
b1bcb2
index 6bc504b7c58..1cc99619ac8 100644
b1bcb2
--- a/grub-core/lib/syslinux_parse.c
b1bcb2
+++ b/grub-core/lib/syslinux_parse.c
b1bcb2
@@ -734,7 +734,10 @@ syslinux_parse_real (struct syslinux_menu *menu)
b1bcb2
 		  && grub_strncasecmp ("help", ptr3, ptr4 - ptr3) == 0))
b1bcb2
 	    {
b1bcb2
 	      if (helptext (ptr5, file, menu))
b1bcb2
-		return 1;
b1bcb2
+		{
b1bcb2
+		  grub_free (buf);
b1bcb2
+		  return 1;
b1bcb2
+		}
b1bcb2
 	      continue;
b1bcb2
 	    }
b1bcb2
 
b1bcb2
@@ -754,6 +757,7 @@ syslinux_parse_real (struct syslinux_menu *menu)
b1bcb2
     }
b1bcb2
  fail:
b1bcb2
   grub_file_close (file);
b1bcb2
+  grub_free (buf);
b1bcb2
   return err;
b1bcb2
 }
b1bcb2