},\r
};\r
\r
+/**\r
+ Free the ARG_LIST.\r
+\r
+ @param List Pointer to ARG_LIST to free.\r
+**/\r
+VOID\r
+IfConfig6FreeArgList (\r
+ ARG_LIST *List\r
+)\r
+{\r
+ ARG_LIST *Next;\r
+ while (List->Next != NULL) {\r
+ Next = List->Next;\r
+ FreePool (List);\r
+ List = Next;\r
+ }\r
+\r
+ FreePool (List);\r
+}\r
+\r
/**\r
Split a string with specified separator and save the substring to a list.\r
\r
//\r
// Copy the CONST string to a local copy.\r
//\r
- Str = AllocateCopyPool (StrSize (String), String);\r
- ASSERT (Str != NULL);\r
+ Str = AllocateCopyPool (StrSize (String), String);\r
+ if (Str == NULL) {\r
+ return NULL;\r
+ }\r
ArgStr = Str;\r
\r
//\r
// init a node for the list head.\r
//\r
ArgNode = (ARG_LIST *) AllocateZeroPool (sizeof (ARG_LIST));\r
- ASSERT (ArgNode != NULL);\r
+ if (ArgNode == NULL) {\r
+ return NULL;\r
+ }\r
ArgList = ArgNode;\r
\r
//\r
ArgNode->Arg = ArgStr;\r
ArgStr = Str + 1;\r
ArgNode->Next = (ARG_LIST *) AllocateZeroPool (sizeof (ARG_LIST));\r
- ASSERT (ArgNode->Next != NULL);\r
+ if (ArgNode->Next == NULL) {\r
+ //\r
+ // Free the local copy of string stored in the first node\r
+ //\r
+ FreePool (ArgList->Arg);\r
+ IfConfig6FreeArgList (ArgList);\r
+ return NULL;\r
+ }\r
ArgNode = ArgNode->Next;\r
}\r
\r
LIST_ENTRY *Entry;\r
LIST_ENTRY *NextEntry;\r
IFCONFIG6_INTERFACE_CB *IfCb;\r
- ARG_LIST *ArgNode;\r
- ARG_LIST *ArgHead;\r
\r
ASSERT (Private != NULL);\r
\r
// Clean the list which save the set config Args.\r
//\r
if (Private->VarArg != NULL) {\r
- ArgHead = Private->VarArg;\r
-\r
- while (ArgHead->Next != NULL) {\r
- ArgNode = ArgHead->Next;\r
- FreePool (ArgHead);\r
- ArgHead = ArgNode;\r
- }\r
-\r
- FreePool (ArgHead);\r
+ IfConfig6FreeArgList (Private->VarArg);\r
}\r
\r
if (Private->IfName != NULL)\r
Private->OpCode = IfConfig6OpList;\r
ValueStr = ShellCommandLineGetValue (ParamPackage, L"-l");\r
if (ValueStr != NULL) {\r
- Str = AllocateCopyPool (StrSize (ValueStr), ValueStr);\r
- ASSERT (Str != NULL);\r
+ Str = AllocateCopyPool (StrSize (ValueStr), ValueStr);\r
+ if (Str == NULL) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellNetwork2HiiHandle, L"ifconfig6");\r
+ ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+ goto ON_EXIT;\r
+ }\r
Private->IfName = Str;\r
}\r
}\r
Private->OpCode = IfConfig6OpClear;\r
ValueStr = ShellCommandLineGetValue (ParamPackage, L"-r");\r
if (ValueStr != NULL) {\r
- Str = AllocateCopyPool (StrSize (ValueStr), ValueStr);\r
- ASSERT (Str != NULL);\r
+ Str = AllocateCopyPool (StrSize (ValueStr), ValueStr);\r
+ if (Str == NULL) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellNetwork2HiiHandle, L"ifconfig6");\r
+ ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+ goto ON_EXIT;\r
+ }\r
Private->IfName = Str;\r
}\r
}\r
//\r
// To split the configuration into multi-section.\r
//\r
- ArgList = IfConfig6SplitStrToList (ValueStr, L' ');\r
- ASSERT (ArgList != NULL);\r
+ ArgList = IfConfig6SplitStrToList (ValueStr, L' ');\r
+ if (ArgList == NULL) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellNetwork2HiiHandle, L"ifconfig6");\r
+ ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+ goto ON_EXIT;\r
+ }\r
\r
Private->OpCode = IfConfig6OpSet;\r
Private->IfName = ArgList->Arg;\r