From 99576ee3fde9228dd5cfedd268f6bc82a0c9f732 Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Tue, 13 Feb 2018 10:23:51 +0800 Subject: [PATCH] MdeModulePkg/BmpSupportLib: Refine type cast for pointer subtraction Since the pointer subtraction here is not performed by pointers to elements of the same array object. This might lead to potential issues, such behavior is undefined according to C11 standard. Refine the pointer subtraction expressions by casting each pointer to UINTN first and then perform the subtraction. Cc: Michael D Kinney Cc: Sean Brogan Cc: Jiewen Yao Cc: Eric Dong Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-by: Star Zeng --- MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c index 2c95e91ecc..467cd6a58d 100644 --- a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c +++ b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c @@ -426,7 +426,7 @@ TranslateBmpToGopBlt ( } - ImageIndex = (UINTN)(Image - ImageHeader); + ImageIndex = (UINTN)Image - (UINTN)ImageHeader; if ((ImageIndex % 4) != 0) { // // Bmp Image starts each row on a 32-bit boundary!