* grub-core/normal/cmdline.c (grub_cmdline_get): Plug memory leak.

This commit is contained in:
Vladimir Serbinenko 2013-11-18 02:43:29 +01:00
parent 33d02a42d6
commit 35d4761ce2
2 changed files with 13 additions and 2 deletions

View file

@ -1,3 +1,7 @@
2013-11-18 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/normal/cmdline.c (grub_cmdline_get): Plug memory leak.
2013-11-18 Vladimir Serbinenko <phcoder@gmail.com> 2013-11-18 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/file.c (grub_file_open): Free file->name on failure. * grub-core/kern/file.c (grub_file_open): Free file->name on failure.

View file

@ -379,12 +379,18 @@ grub_cmdline_get (const char *prompt_translated)
cl_terms = grub_malloc (sizeof (cl_terms[0]) * nterms); cl_terms = grub_malloc (sizeof (cl_terms[0]) * nterms);
if (!cl_terms) if (!cl_terms)
{
grub_free (buf);
return 0; return 0;
}
cl_term_cur = cl_terms; cl_term_cur = cl_terms;
unicode_msg = grub_malloc (msg_len * sizeof (grub_uint32_t)); unicode_msg = grub_malloc (msg_len * sizeof (grub_uint32_t));
if (!unicode_msg) if (!unicode_msg)
return 0;; {
grub_free (buf);
return 0;
}
msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len - 1, msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len - 1,
(grub_uint8_t *) prompt_translated, -1, 0); (grub_uint8_t *) prompt_translated, -1, 0);
unicode_msg[msg_len++] = ' '; unicode_msg[msg_len++] = ' ';
@ -621,6 +627,7 @@ grub_cmdline_get (const char *prompt_translated)
case '\e': case '\e':
grub_free (cl_terms); grub_free (cl_terms);
grub_free (buf);
return 0; return 0;
case '\b': case '\b':