* grub-core/normal/charset.c (grub_utf8_to_ucs4_alloc): Avoid deadloop
on malloc error. (grub_bidi_logical_to_visual): Check that malloc succeded. * grub-core/normal/term.c (grub_puts_terminal): Fix fallback to dumb puts. (grub_xputs_normal): Likewise.
This commit is contained in:
parent
d768d15986
commit
5303b85d44
3 changed files with 61 additions and 23 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2010-08-29 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/normal/charset.c (grub_utf8_to_ucs4_alloc): Avoid deadloop
|
||||||
|
on malloc error.
|
||||||
|
(grub_bidi_logical_to_visual): Check that malloc succeded.
|
||||||
|
* grub-core/normal/term.c (grub_puts_terminal): Fix fallback to dumb
|
||||||
|
puts.
|
||||||
|
(grub_xputs_normal): Likewise.
|
||||||
|
|
||||||
2010-08-29 Vladimir Serbinenko <phcoder@gmail.com>
|
2010-08-29 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/Makefile.core.def (kernel): Add kern/mips/cache_flush.S to
|
* grub-core/Makefile.core.def (kernel): Add kern/mips/cache_flush.S to
|
||||||
|
|
|
@ -297,13 +297,10 @@ grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg,
|
||||||
{
|
{
|
||||||
grub_size_t msg_len = grub_strlen (msg);
|
grub_size_t msg_len = grub_strlen (msg);
|
||||||
|
|
||||||
*unicode_msg = grub_malloc (grub_strlen (msg) * sizeof (grub_uint32_t));
|
*unicode_msg = grub_malloc (msg_len * sizeof (grub_uint32_t));
|
||||||
|
|
||||||
if (!*unicode_msg)
|
if (!*unicode_msg)
|
||||||
{
|
|
||||||
grub_printf ("utf8_to_ucs4 ERROR1: %s", msg);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
msg_len = grub_utf8_to_ucs4 (*unicode_msg, msg_len,
|
msg_len = grub_utf8_to_ucs4 (*unicode_msg, msg_len,
|
||||||
(grub_uint8_t *) msg, -1, 0);
|
(grub_uint8_t *) msg, -1, 0);
|
||||||
|
@ -1215,6 +1212,8 @@ grub_bidi_logical_to_visual (const grub_uint32_t *logical,
|
||||||
struct grub_unicode_glyph *visual_ptr;
|
struct grub_unicode_glyph *visual_ptr;
|
||||||
*visual_out = visual_ptr = grub_malloc (2 * sizeof (visual_ptr[0])
|
*visual_out = visual_ptr = grub_malloc (2 * sizeof (visual_ptr[0])
|
||||||
* logical_len);
|
* logical_len);
|
||||||
|
if (!visual_ptr)
|
||||||
|
return -1;
|
||||||
for (ptr = logical; ptr <= logical + logical_len; ptr++)
|
for (ptr = logical; ptr <= logical + logical_len; ptr++)
|
||||||
{
|
{
|
||||||
if (ptr == logical + logical_len || *ptr == '\n')
|
if (ptr == logical + logical_len || *ptr == '\n')
|
||||||
|
|
|
@ -206,19 +206,36 @@ void
|
||||||
grub_puts_terminal (const char *str, struct grub_term_output *term)
|
grub_puts_terminal (const char *str, struct grub_term_output *term)
|
||||||
{
|
{
|
||||||
grub_uint32_t *unicode_str, *unicode_last_position;
|
grub_uint32_t *unicode_str, *unicode_last_position;
|
||||||
|
grub_error_push ();
|
||||||
grub_utf8_to_ucs4_alloc (str, &unicode_str,
|
grub_utf8_to_ucs4_alloc (str, &unicode_str,
|
||||||
&unicode_last_position);
|
&unicode_last_position);
|
||||||
|
grub_error_pop ();
|
||||||
if (!unicode_str)
|
if (!unicode_str)
|
||||||
{
|
{
|
||||||
for (; str; str++)
|
for (; *str; str++)
|
||||||
{
|
{
|
||||||
grub_uint32_t code = *str;
|
struct grub_unicode_glyph c =
|
||||||
if (code > 0x7f)
|
{
|
||||||
code = '?';
|
.variant = 0,
|
||||||
|
.attributes = 0,
|
||||||
|
.ncomb = 0,
|
||||||
|
.combining = 0,
|
||||||
|
.estimated_width = 1,
|
||||||
|
.base = *str
|
||||||
|
};
|
||||||
|
|
||||||
putcode_real (term, code);
|
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||||
if (code == '\n')
|
{
|
||||||
putcode_real (term, '\r');
|
(term->putchar) (term, &c);
|
||||||
|
}
|
||||||
|
if (*str == '\n')
|
||||||
|
{
|
||||||
|
c.base = '\r';
|
||||||
|
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||||
|
{
|
||||||
|
(term->putchar) (term, &c);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -760,27 +777,40 @@ grub_print_ucs4 (const grub_uint32_t * str,
|
||||||
void
|
void
|
||||||
grub_xputs_normal (const char *str)
|
grub_xputs_normal (const char *str)
|
||||||
{
|
{
|
||||||
grub_term_output_t term;
|
grub_uint32_t *unicode_str = NULL, *unicode_last_position;
|
||||||
grub_uint32_t *unicode_str, *unicode_last_position;
|
|
||||||
int backlog = 0;
|
int backlog = 0;
|
||||||
|
grub_term_output_t term;
|
||||||
|
|
||||||
|
grub_error_push ();
|
||||||
grub_utf8_to_ucs4_alloc (str, &unicode_str,
|
grub_utf8_to_ucs4_alloc (str, &unicode_str,
|
||||||
&unicode_last_position);
|
&unicode_last_position);
|
||||||
|
grub_error_pop ();
|
||||||
|
|
||||||
if (!unicode_str)
|
if (!unicode_str)
|
||||||
{
|
{
|
||||||
grub_errno = GRUB_ERR_NONE;
|
|
||||||
for (; *str; str++)
|
for (; *str; str++)
|
||||||
{
|
{
|
||||||
grub_term_output_t term;
|
struct grub_unicode_glyph c =
|
||||||
grub_uint32_t code = *str;
|
{
|
||||||
if (code > 0x7f)
|
.variant = 0,
|
||||||
code = '?';
|
.attributes = 0,
|
||||||
|
.ncomb = 0,
|
||||||
|
.combining = 0,
|
||||||
|
.estimated_width = 1,
|
||||||
|
.base = *str
|
||||||
|
};
|
||||||
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||||
{
|
{
|
||||||
putcode_real (term, code);
|
(term->putchar) (term, &c);
|
||||||
if (code == '\n')
|
}
|
||||||
putcode_real (term, '\r');
|
if (*str == '\n')
|
||||||
|
{
|
||||||
|
c.base = '\r';
|
||||||
|
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||||
|
{
|
||||||
|
(term->putchar) (term, &c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue