grub2/0326-grub-core-commands-videotest.c-grub_cmd_videotest-Fi.patch
2013-05-02 16:54:52 -04:00

77 lines
2.8 KiB
Diff

From 6ca7e5c09db09a01fad50538908e5d8da439d15b Mon Sep 17 00:00:00 2001
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Date: Fri, 19 Apr 2013 15:09:15 +0200
Subject: [PATCH 326/364] * grub-core/commands/videotest.c
(grub_cmd_videotest): Fix error handling when creating text_layer
failed. * grub-core/video/video.c (grub_video_create_render_target):
Set result to 0 on error. (grub_video_delete_render_target): Do not
dereference NULL.
---
ChangeLog | 8 ++++++++
grub-core/commands/videotest.c | 8 ++++----
grub-core/video/video.c | 3 +++
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3799129..3d4b23d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2013-04-19 Vladimir Serbinenko <phcoder@gmail.com>
+ * grub-core/commands/videotest.c (grub_cmd_videotest): Fix error
+ handling when creating text_layer failed.
+ * grub-core/video/video.c (grub_video_create_render_target):
+ Set result to 0 on error.
+ (grub_video_delete_render_target): Do not dereference NULL.
+
+2013-04-19 Vladimir Serbinenko <phcoder@gmail.com>
+
* grub-core/kern/elfXX.c (grub_elfXX_load): Handle
GRUB_ELF_LOAD_FLAGS_30BITS and GRUB_ELF_LOAD_FLAGS_62BITS.
* grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_load32),
diff --git a/grub-core/commands/videotest.c b/grub-core/commands/videotest.c
index 2e4b3a2..2256237 100644
--- a/grub-core/commands/videotest.c
+++ b/grub-core/commands/videotest.c
@@ -71,10 +71,10 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
grub_font_t fixed;
struct grub_font_glyph *glyph;
- grub_video_create_render_target (&text_layer, width, height,
- GRUB_VIDEO_MODE_TYPE_RGB
- | GRUB_VIDEO_MODE_TYPE_ALPHA);
- if (!text_layer)
+ if (grub_video_create_render_target (&text_layer, width, height,
+ GRUB_VIDEO_MODE_TYPE_RGB
+ | GRUB_VIDEO_MODE_TYPE_ALPHA)
+ || !text_layer)
goto fail;
grub_video_set_active_render_target (text_layer);
diff --git a/grub-core/video/video.c b/grub-core/video/video.c
index aab9b18..844f36c 100644
--- a/grub-core/video/video.c
+++ b/grub-core/video/video.c
@@ -339,6 +339,7 @@ grub_video_create_render_target (struct grub_video_render_target **result,
unsigned int width, unsigned int height,
unsigned int mode_type)
{
+ *result = 0;
if (! grub_video_adapter_active)
return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
@@ -351,6 +352,8 @@ grub_video_create_render_target (struct grub_video_render_target **result,
grub_err_t
grub_video_delete_render_target (struct grub_video_render_target *target)
{
+ if (!target)
+ return GRUB_ERR_NONE;
if (! grub_video_adapter_active)
return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
--
1.8.1.4