[PATCH] UnitTestFrameworkPkg/UnitTestLib: Correct dereferred pointer.


Guomin Jiang
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2609

The copied pointer (SavedState) will be updated by LoadUnitTestCache
call. But the change of SavedState will not update source pointer, which
is NewFramework->SavedState in this case.

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: Guomin Jiang <guomin.jiang@intel.com>
---
UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c b/UnitT=
estFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
index b136992d99..71050b5618 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
@@ -209,7 +209,7 @@ InitUnitTestFramework (
EFI_STATUS Status;=0D
UNIT_TEST_FRAMEWORK_HANDLE NewFrameworkHandle;=0D
UNIT_TEST_FRAMEWORK *NewFramework;=0D
- UNIT_TEST_SAVE_HEADER *SavedState;=0D
+ UNIT_TEST_SAVE_HEADER **SavedState;=0D
=0D
Status =3D EFI_SUCCESS;=0D
NewFramework =3D NULL;=0D
@@ -264,8 +264,8 @@ InitUnitTestFramework (
// If there is a persisted context, load it now.=0D
//=0D
if (DoesCacheExist (NewFrameworkHandle)) {=0D
- SavedState =3D (UNIT_TEST_SAVE_HEADER *)NewFramework->SavedState;=0D
- Status =3D LoadUnitTestCache (NewFrameworkHandle, &SavedState);=0D
+ SavedState =3D (UNIT_TEST_SAVE_HEADER **)(&NewFramework->SavedState);=
=0D
+ Status =3D LoadUnitTestCache (NewFrameworkHandle, SavedState);=0D
if (EFI_ERROR (Status)) {=0D
//=0D
// Don't actually report it as an error, but emit a warning.=0D
--=20
2.25.1.windows.1

Join devel@edk2.groups.io to automatically receive all group messages.