]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
normal: fix memory leak
authorAndrei Borzenkov <arvidjaar@gmail.com>
Tue, 12 Jan 2016 19:36:53 +0000 (22:36 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Tue, 12 Jan 2016 19:40:03 +0000 (22:40 +0300)
Found by: Coverity scan.
CID: 96641, 96670, 96667

grub-core/normal/menu_entry.c
grub-core/normal/term.c

index 2b732250d4febc0755e3166a8819610df5ebb787..b80d161dd92ca66854a153d6c93e66f7c0e50b8d 100644 (file)
@@ -476,7 +476,10 @@ insert_string (struct screen *screen, const char *s, int update)
                                    (grub_uint8_t *) s, (p - s), 0);
 
          if (! ensure_space (current_linep, size))
-           return 0;
+           {
+             grub_free (unicode_msg);
+             return 0;
+           }
 
          grub_memmove (current_linep->buf + screen->column + size,
                        current_linep->buf + screen->column,
@@ -1265,6 +1268,7 @@ grub_menu_entry_run (grub_menu_entry_t entry)
       if (! screen->lines[i].pos)
        {
          grub_print_error ();
+         destroy_screen (screen);
          grub_errno = GRUB_ERR_NONE;
          return;
        }
@@ -1274,6 +1278,7 @@ grub_menu_entry_run (grub_menu_entry_t entry)
   if (!screen->terms)
     {
       grub_print_error ();
+      destroy_screen (screen);
       grub_errno = GRUB_ERR_NONE;
       return;
     }
index 4c2238b25894eab7768690bbddb5cad342991daa..ac5d69f0fb5e0bda21875ec7736fafc96cb6cd9c 100644 (file)
@@ -77,8 +77,6 @@ print_more (void)
   grub_term_output_t term;
   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
      words but don't write poems.  */
   grub_utf8_to_ucs4_alloc (_("--MORE--"), &unicode_str,
@@ -90,6 +88,8 @@ print_more (void)
       return;
     }
 
+  pos = grub_term_save_pos ();
+
   grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
 
   FOR_ACTIVE_TERM_OUTPUTS(term)