]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Fix few memory errors
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 16 Mar 2010 22:03:08 +0000 (23:03 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 16 Mar 2010 22:03:08 +0000 (23:03 +0100)
gfxmenu/font.c
include/grub/unicode.h
normal/charset.c

index 0c973620addf16a5d2784997216ebd6d72ed37fc..a11b31875c4c870c0031987c45031c15a911df1c 100644 (file)
@@ -63,10 +63,10 @@ grub_font_draw_string (const char *str, grub_font_t font,
       if (!glyph)
        return grub_errno;
       err = grub_font_draw_glyph (glyph, color, x, baseline_y);
+      x += glyph->device_width;
       grub_free (glyph);
       if (err)
        return err;
-      x += glyph->device_width;
     }
 
   grub_free (visual);
index c96d8854dc7f2aa4b05c0933ea8af0cbe9a2ea94..b68c7faf5923f48e19387479a34b3ebc5a0e9a0d 100644 (file)
@@ -130,13 +130,16 @@ grub_unicode_glyph_dup (const struct grub_unicode_glyph *in)
   if (!out)
     return NULL;
   grub_memcpy (out, in, sizeof (*in));
-  out->combining = grub_malloc (in->ncomb * sizeof (*in));
-  if (!out->combining)
+  if (in->combining)
     {
-      grub_free (out);
-      return NULL;
+      out->combining = grub_malloc (in->ncomb * sizeof (*in));
+      if (!out->combining)
+       {
+         grub_free (out);
+         return NULL;
+       }
+      grub_memcpy (out->combining, in->combining, in->ncomb * sizeof (*in));
     }
-  grub_memcpy (out->combining, in->combining, in->ncomb * sizeof (*in));
   return out;
 }
 
index 452057174f643135ab80526b465e4089deae2598..2473f1b52c9ed589657210e4ec255bc160414860 100644 (file)
@@ -282,7 +282,8 @@ grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg,
   msg_len = grub_utf8_to_ucs4 (*unicode_msg, msg_len,
                              (grub_uint8_t *) msg, -1, 0);
 
-  *last_position = *unicode_msg + msg_len;
+  if (last_position)
+    *last_position = *unicode_msg + msg_len;
 
   return msg_len;
 }
@@ -529,13 +530,14 @@ grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen,
              || comb_type == GRUB_UNICODE_COMB_ME
              || comb_type == GRUB_UNICODE_COMB_MN)
            last_comb_pointer = out->ncomb;
-         n = grub_realloc (out->combining, 
+         n = grub_realloc (out->combining,
                            sizeof (n[0]) * (out->ncomb + 1));
          if (!n)
            {
              grub_errno = GRUB_ERR_NONE;
              continue;
            }
+         out->combining = n;
 
          for (j = last_comb_pointer; j < out->ncomb; j++)
            if (out->combining[j].type > comb_type)