normal: fix memory leak

Found by: Coverity scan.
CID: 96641, 96670, 96667
This commit is contained in:
Andrei Borzenkov 2016-01-12 22:36:53 +03:00
parent 29862fdc3a
commit 26533fe6bc
2 changed files with 8 additions and 3 deletions

View file

@ -476,7 +476,10 @@ insert_string (struct screen *screen, const char *s, int update)
(grub_uint8_t *) s, (p - s), 0); (grub_uint8_t *) s, (p - s), 0);
if (! ensure_space (current_linep, size)) if (! ensure_space (current_linep, size))
{
grub_free (unicode_msg);
return 0; return 0;
}
grub_memmove (current_linep->buf + screen->column + size, grub_memmove (current_linep->buf + screen->column + size,
current_linep->buf + screen->column, current_linep->buf + screen->column,
@ -1265,6 +1268,7 @@ grub_menu_entry_run (grub_menu_entry_t entry)
if (! screen->lines[i].pos) if (! screen->lines[i].pos)
{ {
grub_print_error (); grub_print_error ();
destroy_screen (screen);
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
return; return;
} }
@ -1274,6 +1278,7 @@ grub_menu_entry_run (grub_menu_entry_t entry)
if (!screen->terms) if (!screen->terms)
{ {
grub_print_error (); grub_print_error ();
destroy_screen (screen);
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
return; return;
} }

View file

@ -77,8 +77,6 @@ print_more (void)
grub_term_output_t term; grub_term_output_t term;
grub_uint32_t *unicode_str, *unicode_last_position; grub_uint32_t *unicode_str, *unicode_last_position;
pos = grub_term_save_pos ();
/* TRANSLATORS: This has to fit on one line. It's ok to include few /* TRANSLATORS: This has to fit on one line. It's ok to include few
words but don't write poems. */ words but don't write poems. */
grub_utf8_to_ucs4_alloc (_("--MORE--"), &unicode_str, grub_utf8_to_ucs4_alloc (_("--MORE--"), &unicode_str,
@ -90,6 +88,8 @@ print_more (void)
return; return;
} }
pos = grub_term_save_pos ();
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
FOR_ACTIVE_TERM_OUTPUTS(term) FOR_ACTIVE_TERM_OUTPUTS(term)