From 1c29d8d5d9060708940f434bc1ecdb6a87db9b4b Mon Sep 17 00:00:00 2001 From: Qiu Shumin Date: Thu, 28 Apr 2016 13:28:53 +0800 Subject: ShellPkg: Add NULL pointer check. Add pointer check to avoid NULL pointer dereferenced. Cc: Jaben Carsey Cc: Tapan Shah Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin Reviewed-by: Tapan Shah (cherry picked from commit 6d3911d40610c01e843a35cefd1fec57f98a4fc2) --- .../UefiHandleParsingLib/UefiHandleParsingLib.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index 58f1814b87..a81d1f208a 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -301,14 +301,26 @@ GraphicsOutputProtocolDumpInformation( SHELL_FREE_NON_NULL (Temp); - Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_GOP_RES_LIST_MAIN), NULL); + Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_GOP_RES_LIST_MAIN), NULL); + if (Temp == NULL) { + SHELL_FREE_NON_NULL (RetVal); + goto EXIT; + } TempRetVal = CatSPrint (RetVal, Temp); - SHELL_FREE_NON_NULL (RetVal); + SHELL_FREE_NON_NULL (RetVal); + if (TempRetVal == NULL) { + goto EXIT; + } RetVal = TempRetVal; SHELL_FREE_NON_NULL (Temp); - Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_GOP_RES_LIST_ENTRY), NULL); + Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_GOP_RES_LIST_ENTRY), NULL); + if (Temp == NULL) { + SHELL_FREE_NON_NULL (RetVal); + goto EXIT; + } + for (Mode = 0; Mode < GraphicsOutput->Mode->MaxMode; Mode++) { Status = GraphicsOutput->QueryMode ( @@ -334,6 +346,8 @@ GraphicsOutputProtocolDumpInformation( RetVal = TempRetVal; } + +EXIT: SHELL_FREE_NON_NULL(Temp); SHELL_FREE_NON_NULL(Fmt); -- cgit v1.2.3