Revision: 15072
          http://sourceforge.net/p/edk2/code/15072
Author:   jcarsey
Date:     2014-01-09 18:02:26 +0000 (Thu, 09 Jan 2014)
Log Message:
-----------
ShellPkg: Fix NSH parsing

This skips lines in NSH files that are completely comments.  This reduces the 
memory overhead and the later processing.

This also frees memory correctly when a second memory allocation fails.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <[email protected]>
Reviewed-by: Ruiyu Ni <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ShellPkg/Application/Shell/Shell.c

Modified: trunk/edk2/ShellPkg/Application/Shell/Shell.c
===================================================================
--- trunk/edk2/ShellPkg/Application/Shell/Shell.c       2014-01-09 17:59:46 UTC 
(rev 15071)
+++ trunk/edk2/ShellPkg/Application/Shell/Shell.c       2014-01-09 18:02:26 UTC 
(rev 15072)
@@ -1067,7 +1067,7 @@
   if (!EFI_ERROR (Status)) {
     CmdLine[BufferSize / sizeof (CHAR16)] = CHAR_NULL;
     Status = RunCommand(CmdLine);
-  }
+    }
 
   //
   // Done with this command
@@ -2362,11 +2362,13 @@
   while(!ShellFileHandleEof(Handle)) {
     CommandLine = ShellFileHandleReturnLine(Handle, &Ascii);
     LineCount++;
-    if (CommandLine == NULL || StrLen(CommandLine) == 0) {
+    if (CommandLine == NULL || StrLen(CommandLine) == 0 || CommandLine[0] == 
'#') {
+      SHELL_FREE_NON_NULL(CommandLine);
       continue;
     }
     NewScriptFile->CurrentCommand = 
AllocateZeroPool(sizeof(SCRIPT_COMMAND_LIST));
     if (NewScriptFile->CurrentCommand == NULL) {
+      SHELL_FREE_NON_NULL(CommandLine);
       DeleteScriptFileStruct(NewScriptFile);
       return (EFI_OUT_OF_RESOURCES);
     }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to