From 15de94cf0514a62702b78030a803a0bb607138ff Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Tue, 28 Mar 2017 10:26:07 +0800 Subject: [PATCH] ShellPkg/Shell: Avoid potential null pointer deference Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Reviewed-by: Hao A Wu --- ShellPkg/Application/Shell/Shell.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c index 5a941aabd0..e91b964d7b 100644 --- a/ShellPkg/Application/Shell/Shell.c +++ b/ShellPkg/Application/Shell/Shell.c @@ -1162,6 +1162,12 @@ LocateStartupScript ( MapName = ShellInfoObject.NewEfiShellProtocol->GetMapFromDevicePath (&ImageDevicePath); if (MapName != NULL) { StartupScriptPath = StrnCatGrow (&StartupScriptPath, &Size, MapName, 0); + if (StartupScriptPath == NULL) { + // + // Do not locate the startup script in sys path when out of resource. + // + return NULL; + } TempSpot = StrStr (StartupScriptPath, L";"); if (TempSpot != NULL) { *TempSpot = CHAR_NULL; -- 2.39.2