Fix a bug in memory allocation

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-08-29 00:19:13 +02:00
parent 328951ac24
commit 04a0a4cdf4

View file

@ -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;