Add assertion to make sure there doesn't exist null pointer dereference.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19308
6f19259b-4bc3-4df7-8a09-
765794883524
if ((SerialDeviceCount != 0) && (RemainingDevicePath != NULL)) {\r
Uart = (UART_DEVICE_PATH *) SkipControllerDevicePathNode (RemainingDevicePath, &ContainsControllerNode, &ControllerNumber);\r
for (Index = 0; Index < SerialDeviceCount; Index++) {\r
if ((SerialDeviceCount != 0) && (RemainingDevicePath != NULL)) {\r
Uart = (UART_DEVICE_PATH *) SkipControllerDevicePathNode (RemainingDevicePath, &ContainsControllerNode, &ControllerNumber);\r
for (Index = 0; Index < SerialDeviceCount; Index++) {\r
+ ASSERT ((SerialDevices != NULL) && (SerialDevices[Index] != NULL));\r
if ((!SerialDevices[Index]->ContainsControllerNode && !ContainsControllerNode) ||\r
(SerialDevices[Index]->ContainsControllerNode && ContainsControllerNode && SerialDevices[Index]->Instance == ControllerNumber)\r
) {\r
if ((!SerialDevices[Index]->ContainsControllerNode && !ContainsControllerNode) ||\r
(SerialDevices[Index]->ContainsControllerNode && ContainsControllerNode && SerialDevices[Index]->Instance == ControllerNumber)\r
) {\r
// Restore the PCI attributes when all children is destroyed (PciDeviceInfo->ChildCount == 0).\r
//\r
PciDeviceInfo = AllocatePool (sizeof (PCI_DEVICE_INFO));\r
// Restore the PCI attributes when all children is destroyed (PciDeviceInfo->ChildCount == 0).\r
//\r
PciDeviceInfo = AllocatePool (sizeof (PCI_DEVICE_INFO));\r
+ ASSERT (PciDeviceInfo != NULL);\r
PciDeviceInfo->ChildCount = 0;\r
PciDeviceInfo->PciIo = ParentIo.PciIo;\r
Status = ParentIo.PciIo->Attributes (\r
PciDeviceInfo->ChildCount = 0;\r
PciDeviceInfo->PciIo = ParentIo.PciIo;\r
Status = ParentIo.PciIo->Attributes (\r
//\r
// Re-use the PciDeviceInfo stored in existing children.\r
//\r
//\r
// Re-use the PciDeviceInfo stored in existing children.\r
//\r
+ ASSERT ((SerialDevices != NULL) && (SerialDevices[0] != NULL));\r
PciDeviceInfo = SerialDevices[0]->PciDeviceInfo;\r
ASSERT (PciDeviceInfo != NULL);\r
}\r
PciDeviceInfo = SerialDevices[0]->PciDeviceInfo;\r
ASSERT (PciDeviceInfo != NULL);\r
}\r