|
|
f96e0b |
From 598550db95b1ca9419a9fb61900fbfa64d468bda Mon Sep 17 00:00:00 2001
|
|
|
f96e0b |
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
Date: Sat, 4 May 2013 13:47:10 +0200
|
|
|
f96e0b |
Subject: [PATCH 418/482] Fix several memory leaks.
|
|
|
f96e0b |
|
|
|
f96e0b |
---
|
|
|
f96e0b |
ChangeLog | 4 +++
|
|
|
f96e0b |
grub-core/gfxmenu/font.c | 2 ++
|
|
|
f96e0b |
grub-core/gfxmenu/gfxmenu.c | 2 +-
|
|
|
f96e0b |
grub-core/gfxmenu/gui_list.c | 5 +++-
|
|
|
f96e0b |
grub-core/gfxmenu/gui_progress_bar.c | 1 +
|
|
|
f96e0b |
grub-core/normal/context.c | 2 ++
|
|
|
f96e0b |
grub-core/normal/main.c | 2 ++
|
|
|
f96e0b |
grub-core/normal/menu_entry.c | 10 +++++++-
|
|
|
f96e0b |
grub-core/normal/menu_text.c | 5 +++-
|
|
|
f96e0b |
grub-core/normal/term.c | 2 ++
|
|
|
f96e0b |
grub-core/term/gfxterm.c | 47 +++++++++++++++++++++++++++++-------
|
|
|
f96e0b |
grub-core/tests/lib/test.c | 3 ++-
|
|
|
f96e0b |
grub-core/video/capture.c | 1 +
|
|
|
f96e0b |
13 files changed, 72 insertions(+), 14 deletions(-)
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/ChangeLog b/ChangeLog
|
|
|
f96e0b |
index 6b0576d..47f06fd 100644
|
|
|
f96e0b |
--- a/ChangeLog
|
|
|
f96e0b |
+++ b/ChangeLog
|
|
|
f96e0b |
@@ -1,5 +1,9 @@
|
|
|
f96e0b |
2013-05-04 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
|
|
|
f96e0b |
+ Fix several memory leaks.
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+2013-05-04 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
+
|
|
|
f96e0b |
* grub-core/normal/menu.c (run_menu): Fix timeout reference point.
|
|
|
f96e0b |
|
|
|
f96e0b |
2013-05-04 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
diff --git a/grub-core/gfxmenu/font.c b/grub-core/gfxmenu/font.c
|
|
|
f96e0b |
index 4a8e1f1..9c6e2d4 100644
|
|
|
f96e0b |
--- a/grub-core/gfxmenu/font.c
|
|
|
f96e0b |
+++ b/grub-core/gfxmenu/font.c
|
|
|
f96e0b |
@@ -70,6 +70,8 @@ grub_font_draw_string (const char *str, grub_font_t font,
|
|
|
f96e0b |
return err;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
+ for (ptr = visual; ptr < visual + visual_len; ptr++)
|
|
|
f96e0b |
+ grub_free (ptr->combining);
|
|
|
f96e0b |
grub_free (visual);
|
|
|
f96e0b |
|
|
|
f96e0b |
return GRUB_ERR_NONE;
|
|
|
f96e0b |
diff --git a/grub-core/gfxmenu/gfxmenu.c b/grub-core/gfxmenu/gfxmenu.c
|
|
|
f96e0b |
index 51110a6..f49fce8 100644
|
|
|
f96e0b |
--- a/grub-core/gfxmenu/gfxmenu.c
|
|
|
f96e0b |
+++ b/grub-core/gfxmenu/gfxmenu.c
|
|
|
f96e0b |
@@ -85,7 +85,7 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested)
|
|
|
f96e0b |
|| cached_view->screen.width != mode_info.width
|
|
|
f96e0b |
|| cached_view->screen.height != mode_info.height)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_free (cached_view);
|
|
|
f96e0b |
+ grub_gfxmenu_view_destroy (cached_view);
|
|
|
f96e0b |
/* Create the view. */
|
|
|
f96e0b |
cached_view = grub_gfxmenu_view_new (full_theme_path ? : theme_path,
|
|
|
f96e0b |
mode_info.width,
|
|
|
f96e0b |
diff --git a/grub-core/gfxmenu/gui_list.c b/grub-core/gfxmenu/gui_list.c
|
|
|
f96e0b |
index a06603b..1a2a16d 100644
|
|
|
f96e0b |
--- a/grub-core/gfxmenu/gui_list.c
|
|
|
f96e0b |
+++ b/grub-core/gfxmenu/gui_list.c
|
|
|
f96e0b |
@@ -83,7 +83,10 @@ list_destroy (void *vself)
|
|
|
f96e0b |
self->selected_item_box->destroy (self->selected_item_box);
|
|
|
f96e0b |
if (self->icon_manager)
|
|
|
f96e0b |
grub_gfxmenu_icon_manager_destroy (self->icon_manager);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
+ if (self->scrollbar_thumb)
|
|
|
f96e0b |
+ self->scrollbar_thumb->destroy (self->scrollbar_thumb);
|
|
|
f96e0b |
+ if (self->scrollbar_frame)
|
|
|
f96e0b |
+ self->scrollbar_frame->destroy (self->scrollbar_frame);
|
|
|
f96e0b |
grub_free (self);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/grub-core/gfxmenu/gui_progress_bar.c b/grub-core/gfxmenu/gui_progress_bar.c
|
|
|
f96e0b |
index 965c6b3..cb70930 100644
|
|
|
f96e0b |
--- a/grub-core/gfxmenu/gui_progress_bar.c
|
|
|
f96e0b |
+++ b/grub-core/gfxmenu/gui_progress_bar.c
|
|
|
f96e0b |
@@ -185,6 +185,7 @@ draw_text (grub_gui_progress_bar_t self)
|
|
|
f96e0b |
int y = ((height - grub_font_get_descent (font)) / 2
|
|
|
f96e0b |
+ grub_font_get_ascent (font) / 2);
|
|
|
f96e0b |
grub_font_draw_string (text, font, text_color, x, y);
|
|
|
f96e0b |
+ grub_free (text);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c
|
|
|
f96e0b |
index e9923cc..7e0a696 100644
|
|
|
f96e0b |
--- a/grub-core/normal/context.c
|
|
|
f96e0b |
+++ b/grub-core/normal/context.c
|
|
|
f96e0b |
@@ -139,6 +139,8 @@ grub_env_context_close (void)
|
|
|
f96e0b |
grub_current_context = context;
|
|
|
f96e0b |
|
|
|
f96e0b |
menu = current_menu->prev;
|
|
|
f96e0b |
+ if (current_menu->menu)
|
|
|
f96e0b |
+ grub_normal_free_menu (current_menu->menu);
|
|
|
f96e0b |
grub_free (current_menu);
|
|
|
f96e0b |
current_menu = menu;
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
|
|
|
f96e0b |
index 759e0a4..f7a815f 100644
|
|
|
f96e0b |
--- a/grub-core/normal/main.c
|
|
|
f96e0b |
+++ b/grub-core/normal/main.c
|
|
|
f96e0b |
@@ -127,6 +127,7 @@ grub_normal_free_menu (grub_menu_t menu)
|
|
|
f96e0b |
grub_free ((void *) entry->users);
|
|
|
f96e0b |
grub_free ((void *) entry->title);
|
|
|
f96e0b |
grub_free ((void *) entry->sourcecode);
|
|
|
f96e0b |
+ grub_free (entry);
|
|
|
f96e0b |
entry = next_entry;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -191,6 +192,7 @@ read_config_file (const char *config)
|
|
|
f96e0b |
if (ptr)
|
|
|
f96e0b |
*ptr = 0;
|
|
|
f96e0b |
grub_env_set ("config_directory", config_dir);
|
|
|
f96e0b |
+ grub_free (config_dir);
|
|
|
f96e0b |
|
|
|
f96e0b |
grub_env_export ("config_file");
|
|
|
f96e0b |
grub_env_export ("config_directory");
|
|
|
f96e0b |
diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
|
|
|
f96e0b |
index e0407aa..3cc0c01 100644
|
|
|
f96e0b |
--- a/grub-core/normal/menu_entry.c
|
|
|
f96e0b |
+++ b/grub-core/normal/menu_entry.c
|
|
|
f96e0b |
@@ -517,7 +517,15 @@ destroy_screen (struct screen *screen)
|
|
|
f96e0b |
struct line *linep = screen->lines + i;
|
|
|
f96e0b |
|
|
|
f96e0b |
if (linep)
|
|
|
f96e0b |
- grub_free (linep->buf);
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ unsigned j;
|
|
|
f96e0b |
+ if (linep->pos)
|
|
|
f96e0b |
+ for (j = 0; j < screen->nterms; j++)
|
|
|
f96e0b |
+ grub_free (linep->pos[j]);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ grub_free (linep->buf);
|
|
|
f96e0b |
+ grub_free (linep->pos);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
grub_free (screen->killed_text);
|
|
|
f96e0b |
diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c
|
|
|
f96e0b |
index e1d3c8f..19a5389 100644
|
|
|
f96e0b |
--- a/grub-core/normal/menu_text.c
|
|
|
f96e0b |
+++ b/grub-core/normal/menu_text.c
|
|
|
f96e0b |
@@ -56,8 +56,10 @@ grub_getstringwidth (grub_uint32_t * str, const grub_uint32_t * last_position,
|
|
|
f96e0b |
while (str < last_position)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
struct grub_unicode_glyph glyph;
|
|
|
f96e0b |
+ glyph.combining = 0;
|
|
|
f96e0b |
str += grub_unicode_aglomerate_comb (str, last_position - str, &glyph);
|
|
|
f96e0b |
width += grub_term_getcharwidth (term, &glyph);
|
|
|
f96e0b |
+ grub_free (glyph.combining);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
return width;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
@@ -396,6 +398,7 @@ menu_text_print_timeout (int timeout, void *dataptr)
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
grub_print_message_indented (msg_translated, 3, 0, data->term);
|
|
|
f96e0b |
+ grub_free (msg_translated);
|
|
|
f96e0b |
|
|
|
f96e0b |
posx = grub_term_getxy (data->term) >> 8;
|
|
|
f96e0b |
grub_print_spaces (data->term, grub_term_width (data->term) - posx - 1);
|
|
|
f96e0b |
@@ -447,7 +450,7 @@ menu_text_fini (void *dataptr)
|
|
|
f96e0b |
|
|
|
f96e0b |
grub_term_setcursor (data->term, 1);
|
|
|
f96e0b |
grub_term_cls (data->term);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
+ grub_free (data);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
static void
|
|
|
f96e0b |
diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c
|
|
|
f96e0b |
index 9764423..820156f 100644
|
|
|
f96e0b |
--- a/grub-core/normal/term.c
|
|
|
f96e0b |
+++ b/grub-core/normal/term.c
|
|
|
f96e0b |
@@ -952,6 +952,8 @@ print_ucs4_real (const grub_uint32_t * str,
|
|
|
f96e0b |
ret++;
|
|
|
f96e0b |
if (visual_len_show && visual[visual_len_show - 1].base != '\n')
|
|
|
f96e0b |
ret++;
|
|
|
f96e0b |
+ for (vptr = visual; vptr < visual + visual_len; vptr++)
|
|
|
f96e0b |
+ grub_free (vptr->combining);
|
|
|
f96e0b |
grub_free (visual);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
else
|
|
|
f96e0b |
diff --git a/grub-core/term/gfxterm.c b/grub-core/term/gfxterm.c
|
|
|
f96e0b |
index a168e01..1e33a34 100644
|
|
|
f96e0b |
--- a/grub-core/term/gfxterm.c
|
|
|
f96e0b |
+++ b/grub-core/term/gfxterm.c
|
|
|
f96e0b |
@@ -175,7 +175,11 @@ set_term_color (grub_uint8_t term_color)
|
|
|
f96e0b |
static void
|
|
|
f96e0b |
clear_char (struct grub_colored_char *c)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_free (c->code);
|
|
|
f96e0b |
+ if (c->code)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_free (c->code->combining);
|
|
|
f96e0b |
+ grub_free (c->code);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
c->code = grub_unicode_glyph_from_code (' ');
|
|
|
f96e0b |
if (!c->code)
|
|
|
f96e0b |
grub_errno = GRUB_ERR_NONE;
|
|
|
f96e0b |
@@ -188,7 +192,18 @@ grub_virtual_screen_free (void)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
/* If virtual screen has been allocated, free it. */
|
|
|
f96e0b |
if (virtual_screen.text_buffer != 0)
|
|
|
f96e0b |
- grub_free (virtual_screen.text_buffer);
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ unsigned i;
|
|
|
f96e0b |
+ for (i = 0;
|
|
|
f96e0b |
+ i < virtual_screen.columns * virtual_screen.rows;
|
|
|
f96e0b |
+ i++)
|
|
|
f96e0b |
+ if (virtual_screen.text_buffer[i].code)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_free (virtual_screen.text_buffer[i].code->combining);
|
|
|
f96e0b |
+ grub_free (virtual_screen.text_buffer[i].code);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ grub_free (virtual_screen.text_buffer);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Reset virtual screen data. */
|
|
|
f96e0b |
grub_memset (&virtual_screen, 0, sizeof (virtual_screen));
|
|
|
f96e0b |
@@ -403,7 +418,11 @@ grub_gfxterm_term_fini (struct grub_term_output *term __attribute__ ((unused)))
|
|
|
f96e0b |
|
|
|
f96e0b |
for (i = 0; i < virtual_screen.columns * virtual_screen.rows; i++)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_free (virtual_screen.text_buffer[i].code);
|
|
|
f96e0b |
+ if (virtual_screen.text_buffer[i].code)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_free (virtual_screen.text_buffer[i].code->combining);
|
|
|
f96e0b |
+ grub_free (virtual_screen.text_buffer[i].code);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
virtual_screen.text_buffer[i].code = 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -798,7 +817,11 @@ scroll_up (void)
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Clear first line in text buffer. */
|
|
|
f96e0b |
for (i = 0; i < virtual_screen.columns; i++)
|
|
|
f96e0b |
- grub_free (virtual_screen.text_buffer[i].code);
|
|
|
f96e0b |
+ if (virtual_screen.text_buffer[i].code)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_free (virtual_screen.text_buffer[i].code->combining);
|
|
|
f96e0b |
+ grub_free (virtual_screen.text_buffer[i].code);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Scroll text buffer with one line to up. */
|
|
|
f96e0b |
grub_memmove (virtual_screen.text_buffer,
|
|
|
f96e0b |
@@ -874,7 +897,11 @@ grub_gfxterm_putchar (struct grub_term_output *term,
|
|
|
f96e0b |
p = (virtual_screen.text_buffer +
|
|
|
f96e0b |
virtual_screen.cursor_x +
|
|
|
f96e0b |
virtual_screen.cursor_y * virtual_screen.columns);
|
|
|
f96e0b |
- grub_free (p->code);
|
|
|
f96e0b |
+ if (p->code)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_free (p->code->combining);
|
|
|
f96e0b |
+ grub_free (p->code);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
p->code = grub_unicode_glyph_dup (c);
|
|
|
f96e0b |
if (!p->code)
|
|
|
f96e0b |
grub_errno = GRUB_ERR_NONE;
|
|
|
f96e0b |
@@ -889,10 +916,12 @@ grub_gfxterm_putchar (struct grub_term_output *term,
|
|
|
f96e0b |
for (i = 1; i < char_width && p + i <
|
|
|
f96e0b |
virtual_screen.text_buffer + virtual_screen.columns
|
|
|
f96e0b |
* virtual_screen.rows; i++)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- grub_free (p[i].code);
|
|
|
f96e0b |
- p[i].code = NULL;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
+ if (p[i].code)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_free (p[i].code->combining);
|
|
|
f96e0b |
+ grub_free (p[i].code);
|
|
|
f96e0b |
+ p[i].code = NULL;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Draw glyph. */
|
|
|
f96e0b |
diff --git a/grub-core/tests/lib/test.c b/grub-core/tests/lib/test.c
|
|
|
f96e0b |
index 1d2cb8c..3000fc8 100644
|
|
|
f96e0b |
--- a/grub-core/tests/lib/test.c
|
|
|
f96e0b |
+++ b/grub-core/tests/lib/test.c
|
|
|
f96e0b |
@@ -87,7 +87,8 @@ failure_append_vtext(grub_test_failure_t failure, const char *fmt, va_list args)
|
|
|
f96e0b |
char *oldmsg = failure->message;
|
|
|
f96e0b |
|
|
|
f96e0b |
failure->message = grub_xasprintf("%s%s", oldmsg, msg);
|
|
|
f96e0b |
- grub_free(oldmsg);
|
|
|
f96e0b |
+ grub_free (oldmsg);
|
|
|
f96e0b |
+ grub_free (msg);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
else
|
|
|
f96e0b |
{
|
|
|
f96e0b |
diff --git a/grub-core/video/capture.c b/grub-core/video/capture.c
|
|
|
f96e0b |
index be7fb61..18ffa28 100644
|
|
|
f96e0b |
--- a/grub-core/video/capture.c
|
|
|
f96e0b |
+++ b/grub-core/video/capture.c
|
|
|
f96e0b |
@@ -115,6 +115,7 @@ grub_video_capture_get_framebuffer (void)
|
|
|
f96e0b |
void
|
|
|
f96e0b |
grub_video_capture_end (void)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
+ grub_video_fb_delete_render_target (framebuffer.render_target);
|
|
|
f96e0b |
grub_free (framebuffer.ptr);
|
|
|
f96e0b |
grub_video_fb_fini ();
|
|
|
f96e0b |
grub_video_adapter_active = saved;
|
|
|
f96e0b |
--
|
|
|
f96e0b |
1.8.2.1
|
|
|
f96e0b |
|