0086-loader-xnu-Fix-memory-leak.patch 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. From bcb59ece3263d118510c4440c4da0950f224bb7f Mon Sep 17 00:00:00 2001
  2. From: Darren Kenny <darren.kenny@oracle.com>
  3. Date: Thu, 26 Nov 2020 12:53:10 +0000
  4. Subject: [PATCH] loader/xnu: Fix memory leak
  5. The code here is finished with the memory stored in name, but it only
  6. frees it if there curvalue is valid, while it could actually free it
  7. regardless.
  8. The fix is a simple relocation of the grub_free() to before the test
  9. of curvalue.
  10. Fixes: CID 96646
  11. Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
  12. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  13. Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
  14. ---
  15. grub-core/loader/xnu.c | 2 +-
  16. 1 file changed, 1 insertion(+), 1 deletion(-)
  17. diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c
  18. index 44fd5a9..eb14462 100644
  19. --- a/grub-core/loader/xnu.c
  20. +++ b/grub-core/loader/xnu.c
  21. @@ -1391,9 +1391,9 @@ grub_xnu_fill_devicetree (void)
  22. name[len] = 0;
  23. curvalue = grub_xnu_create_value (curkey, name);
  24. + grub_free (name);
  25. if (!curvalue)
  26. return grub_errno;
  27. - grub_free (name);
  28. data = grub_malloc (grub_strlen (var->value) + 1);
  29. if (!data)
  30. --
  31. 2.14.2