UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use.

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>
This commit is contained in:
GuoMinJ 2020-03-05 14:17:47 +08:00 committed by mergify[bot]
parent 090e267b5b
commit 5bc09cf05a
2 changed files with 4 additions and 4 deletions

View File

@ -33,13 +33,13 @@ RunTestSuite (
UNIT_TEST *Test; UNIT_TEST *Test;
UNIT_TEST_FRAMEWORK *ParentFramework; UNIT_TEST_FRAMEWORK *ParentFramework;
TestEntry = NULL;
ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
if (Suite == NULL) { if (Suite == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
TestEntry = NULL;
ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n")); DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n"));
DEBUG ((DEBUG_VERBOSE, "RUNNING TEST SUITE: %a\n", Suite->Title)); DEBUG ((DEBUG_VERBOSE, "RUNNING TEST SUITE: %a\n", Suite->Title));
DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n")); DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n"));

View File

@ -436,7 +436,6 @@ AddTestCase (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
Suite = (UNIT_TEST_SUITE *)SuiteHandle; Suite = (UNIT_TEST_SUITE *)SuiteHandle;
ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
// //
// First, let's check to make sure that our parameters look good. // First, let's check to make sure that our parameters look good.
@ -445,6 +444,7 @@ AddTestCase (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
// //
// Create the new entry. // Create the new entry.
NewTestEntry = AllocateZeroPool (sizeof( UNIT_TEST_LIST_ENTRY )); NewTestEntry = AllocateZeroPool (sizeof( UNIT_TEST_LIST_ENTRY ));