]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Fix a bug in memory allocation
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 28 Aug 2010 22:19:13 +0000 (00:19 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 28 Aug 2010 22:19:13 +0000 (00:19 +0200)
grub-core/kern/mm.c

index dec07bc1be68fda797772ad502e4a672324d26a5..8d9b5db78ad6ccb9c1132f447c1893b356b3cd14 100644 (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;