diff --git a/ChangeLog b/ChangeLog index 612669367..0b9d6c30a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-08-28 Vladimir Serbinenko + + * 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 * grub-core/script/lexer.c (grub_script_lexer_init): Don't look before diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c index 4f5779abe..e6ef002d0 100644 --- a/grub-core/normal/term.c +++ b/grub-core/normal/term.c @@ -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; }