Adding a fix for memory leaks. In case of overflow check fails, not freeing 'p' and 'p->grub_devpath' will result in memory leaks.
Signed-off-by: Avnish Chouhan <[email protected]> --- grub-core/disk/ieee1275/ofdisk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index dbc0f1a..3a90a71 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -93,6 +93,7 @@ ofdisk_hash_add_real (char *devpath) grub_add (sz, sizeof ("ieee1275/"), &sz)) { grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow detected while obtaining size of device path")); + grub_free (p); return NULL; } @@ -108,8 +109,10 @@ ofdisk_hash_add_real (char *devpath) { if (grub_add (grub_strlen (p->devpath), 3, &sz)) { - grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow detected while obtaining size of an open path")); - return NULL; + grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow detected while obtaining size of an open path")); + grub_free (p->grub_devpath); + grub_free (p); + return NULL; } p->open_path = grub_malloc (sz); -- 2.52.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
