From 29666911f7291658004e1732514ed8ebf7040f13 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Sun, 1 Feb 2009 04:48:29 +0000 Subject: Add check when use *Pointer as Sd->mRight[*Pointer] to avoid out of Array bound. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7382 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c index 9d0fd7d131..6dc1b84b87 100644 --- a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c +++ b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c @@ -225,11 +225,13 @@ MakeTable ( Sd->mRight[Avail] = Sd->mLeft[Avail] = 0; *Pointer = Avail++; } - - if ((Index3 & Mask) != 0) { - Pointer = &Sd->mRight[*Pointer]; - } else { - Pointer = &Sd->mLeft[*Pointer]; + + if (*Pointer < (2 * NC - 1)) { + if ((Index3 & Mask) != 0) { + Pointer = &Sd->mRight[*Pointer]; + } else { + Pointer = &Sd->mLeft[*Pointer]; + } } Index3 <<= 1; -- cgit v1.2.3