]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use.
authorGuoMinJ <newexplorerj@gmail.com>
Thu, 5 Mar 2020 06:17:47 +0000 (14:17 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 27 Mar 2020 02:03:41 +0000 (02:03 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2530

The Suite pointer is used before check if it is valid,
correct it to check the validation before use.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: GuoMinJ <newexplorerj@gmail.com>
Reviewed-by: Shenglei Zhang <shenglei.zhang@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c

index fb247c59e75c2cb3d2931a822a57b8e613c571f4..b053e04959120cf4a04d4d0b32e6a9bbe574ed44 100644 (file)
@@ -33,13 +33,13 @@ RunTestSuite (
   UNIT_TEST             *Test;\r
   UNIT_TEST_FRAMEWORK   *ParentFramework;\r
 \r
-  TestEntry       = NULL;\r
-  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;\r
-\r
   if (Suite == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  TestEntry       = NULL;\r
+  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;\r
+\r
   DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n"));\r
   DEBUG ((DEBUG_VERBOSE, "RUNNING TEST SUITE: %a\n", Suite->Title));\r
   DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n"));\r
index fd15991ea4e9bea845bb2dda163a1be61bd74f63..b136992d99a0774228ed656d95d676d0d45139e0 100644 (file)
@@ -436,7 +436,6 @@ AddTestCase (
 \r
   Status          = EFI_SUCCESS;\r
   Suite           = (UNIT_TEST_SUITE *)SuiteHandle;\r
-  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;\r
 \r
   //\r
   // First, let's check to make sure that our parameters look good.\r
@@ -445,6 +444,7 @@ AddTestCase (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;\r
   //\r
   // Create the new entry.\r
   NewTestEntry = AllocateZeroPool (sizeof( UNIT_TEST_LIST_ENTRY ));\r