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);