From: Vladimir 'phcoder' Serbinenko Date: Sat, 28 Aug 2010 22:19:13 +0000 (+0200) Subject: Fix a bug in memory allocation X-Git-Tag: 1.99~629^2~20 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=04a0a4cdf4bfd778b7992491b73c78fd74163234;p=thirdparty%2Fgrub.git Fix a bug in memory allocation --- diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c index dec07bc1b..8d9b5db78 100644 --- a/grub-core/kern/mm.c +++ b/grub-core/kern/mm.c @@ -171,6 +171,7 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) if (p->size >= n + extra) { + extra += (p->size - extra - n) & (~(align - 1)); if (extra == 0 && p->size == n) { /* There is no special alignment requirement and memory block @@ -246,7 +247,6 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) */ grub_mm_header_t r; - extra += (p->size - extra - n) & (~(align - 1)); r = p + extra + n; r->magic = GRUB_MM_FREE_MAGIC; r->size = p->size - extra - n;