From 9891039b06cae894b408a079e27f00d8f3299d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20Kentt=C3=A4?= Date: Sat, 14 May 2016 10:51:21 +0300 Subject: [PATCH] Fix a potentian null pointer reference If GOP is not available and there's no old_bmp, the coordinates can't be automatically calculated. --- src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 3108ea5..d327542 100644 --- a/src/main.c +++ b/src/main.c @@ -81,11 +81,11 @@ static void FillBGRT(ACPI_BGRT* bgrt, BMP* new_bmp, int new_x, int new_y) { BMP* bmp = (BMP*) (UINTN) bgrt->image_address; // Calculate the automatically centered position for the image. - int x_auto, y_auto; + int x_auto = 0, y_auto = 0; if (GOP()) { x_auto = max(0, ((int)GOP()->Mode->Info->HorizontalResolution - (int)bmp->width) / 2); y_auto = max(0, ((int)GOP()->Mode->Info->VerticalResolution * 2/3 - (int)bmp->height) / 2); - } else { + } else if (old_bmp) { x_auto = max(0, (int)bgrt0.image_offset_x + ((int)old_bmp->width - (int)bmp->width) / 2); y_auto = max(0, (int)bgrt0.image_offset_y + ((int)old_bmp->height - (int)bmp->height) / 2); }