]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/normal/term.c (print_more): Fix a memory leak.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 28 Aug 2010 13:39:34 +0000 (15:39 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 28 Aug 2010 13:39:34 +0000 (15:39 +0200)
(grub_puts_terminal): Revert to dumb puts if memory allocation fails.
(grub_xputs_normal): Likewise.

ChangeLog
grub-core/normal/term.c

index 612669367d63af475bf667993441941a2b773f76..0b9d6c30ac79a410fc1232e12470b993bf0d292a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-08-28  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/normal/term.c (print_more): Fix a memory leak.
+       (grub_puts_terminal): Revert to dumb puts if memory allocation fails.
+       (grub_xputs_normal): Likewise.
+
 2010-08-28  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/script/lexer.c (grub_script_lexer_init): Don't look before
index 4f5779abe5c711efccb712d116fb0fb4ee33e651..e6ef002d00a3df182353ca394e1a78eac2f0ed15 100644 (file)
@@ -44,6 +44,9 @@ static int grub_more;
 
 static int grub_normal_char_counter = 0;
 
+static void
+putcode_real (grub_uint32_t code, struct grub_term_output *term);
+
 int
 grub_normal_get_char_counter (void)
 {
@@ -94,6 +97,7 @@ print_more (void)
   FOR_ACTIVE_TERM_OUTPUTS(term)
     grub_print_spaces (term, 8);
   grub_term_restore_pos (pos);
+  grub_free (pos);
 
   /* Scroll one lines or an entire page, depending on the key.  */
 
@@ -204,6 +208,20 @@ grub_puts_terminal (const char *str, struct grub_term_output *term)
   grub_uint32_t *unicode_str, *unicode_last_position;
   grub_utf8_to_ucs4_alloc (str, &unicode_str,
                           &unicode_last_position);
+  if (!unicode_str)
+    {
+      for (; str; str++)
+       {
+         grub_uint32_t code = *str;
+         if (code > 0x7f)
+           code = '?';
+
+         putcode_real (term, code);
+         if (code == '\n')
+           putcode_real (term, '\r');
+       }
+      return;
+    }
 
   grub_print_ucs4 (unicode_str, unicode_last_position, 0, 0, term);
   grub_free (unicode_str);
@@ -751,6 +769,21 @@ grub_xputs_normal (const char *str)
   if (!unicode_str)
     {
       grub_errno = GRUB_ERR_NONE;
+      for (; *str; str++)
+       {
+         grub_term_output_t term;
+         grub_uint32_t code = *str;
+         if (code > 0x7f)
+           code = '?';
+
+         FOR_ACTIVE_TERM_OUTPUTS(term)
+         {
+           putcode_real (term, code);
+           if (code == '\n')
+             putcode_real (term, '\r');
+         }
+       }
+
       return;
     }