summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuoMinJ <newexplorerj@gmail.com>2020-03-05 14:17:47 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-03-27 02:03:41 +0000
commit5bc09cf05a98784d483d9bb9d95a65f14eadb5f6 (patch)
treefa01ae3a940cc54df702c891ba158e0d8a567e8a
parent090e267b5bb594d9f2dbe38b2b3562347773826a (diff)
downloadedk2-5bc09cf05a98784d483d9bb9d95a65f14eadb5f6.tar.gz
edk2-5bc09cf05a98784d483d9bb9d95a65f14eadb5f6.tar.bz2
edk2-5bc09cf05a98784d483d9bb9d95a65f14eadb5f6.zip
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>
-rw-r--r--UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c6
-rw-r--r--UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
index fb247c59e7..b053e04959 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
@@ -33,13 +33,13 @@ RunTestSuite (
UNIT_TEST *Test;
UNIT_TEST_FRAMEWORK *ParentFramework;
- TestEntry = NULL;
- ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
-
if (Suite == NULL) {
return EFI_INVALID_PARAMETER;
}
+ TestEntry = NULL;
+ ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
+
DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n"));
DEBUG ((DEBUG_VERBOSE, "RUNNING TEST SUITE: %a\n", Suite->Title));
DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n"));
diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
index fd15991ea4..b136992d99 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
@@ -436,7 +436,6 @@ AddTestCase (
Status = EFI_SUCCESS;
Suite = (UNIT_TEST_SUITE *)SuiteHandle;
- ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
//
// First, let's check to make sure that our parameters look good.
@@ -445,6 +444,7 @@ AddTestCase (
return EFI_INVALID_PARAMETER;
}
+ ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
//
// Create the new entry.
NewTestEntry = AllocateZeroPool (sizeof( UNIT_TEST_LIST_ENTRY ));