ShellPkg: Add NULL pointer check.

Add pointer check to avoid NULL pointer dereferenced.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Tapan Shah <tapandshah@hpe.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hpe.com>
This commit is contained in:
Qiu Shumin 2016-04-28 13:28:53 +08:00
parent 91f51fcc84
commit 6d3911d406
1 changed files with 17 additions and 3 deletions

View File

@ -301,14 +301,26 @@ GraphicsOutputProtocolDumpInformation(
SHELL_FREE_NON_NULL (Temp); 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); TempRetVal = CatSPrint (RetVal, Temp);
SHELL_FREE_NON_NULL (RetVal); SHELL_FREE_NON_NULL (RetVal);
if (TempRetVal == NULL) {
goto EXIT;
}
RetVal = TempRetVal; RetVal = TempRetVal;
SHELL_FREE_NON_NULL (Temp); 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++) { for (Mode = 0; Mode < GraphicsOutput->Mode->MaxMode; Mode++) {
Status = GraphicsOutput->QueryMode ( Status = GraphicsOutput->QueryMode (
@ -334,6 +346,8 @@ GraphicsOutputProtocolDumpInformation(
RetVal = TempRetVal; RetVal = TempRetVal;
} }
EXIT:
SHELL_FREE_NON_NULL(Temp); SHELL_FREE_NON_NULL(Temp);
SHELL_FREE_NON_NULL(Fmt); SHELL_FREE_NON_NULL(Fmt);