[edk2-devel] [PATCH] UnitTestFrameworkPkg/UnitTestLib: Correct dereferred pointer.

Guomin Jiang posted 1 patch 3 years, 12 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/edk2 tags/patchew/20200331064940.1739-1-guomin.jiang@intel.com
UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[edk2-devel] [PATCH] UnitTestFrameworkPkg/UnitTestLib: Correct dereferred pointer.
Posted by Guomin Jiang 3 years, 12 months ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2609

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/UnitTestFrameworkPkg/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;
   UNIT_TEST_FRAMEWORK_HANDLE  NewFrameworkHandle;
   UNIT_TEST_FRAMEWORK         *NewFramework;
-  UNIT_TEST_SAVE_HEADER       *SavedState;
+  UNIT_TEST_SAVE_HEADER       **SavedState;
 
   Status       = EFI_SUCCESS;
   NewFramework = NULL;
@@ -264,8 +264,8 @@ InitUnitTestFramework (
   // If there is a persisted context, load it now.
   //
   if (DoesCacheExist (NewFrameworkHandle)) {
-    SavedState = (UNIT_TEST_SAVE_HEADER *)NewFramework->SavedState;
-    Status = LoadUnitTestCache (NewFrameworkHandle, &SavedState);
+    SavedState = (UNIT_TEST_SAVE_HEADER **)(&NewFramework->SavedState);
+    Status = LoadUnitTestCache (NewFrameworkHandle, SavedState);
     if (EFI_ERROR (Status)) {
       //
       // Don't actually report it as an error, but emit a warning.
-- 
2.25.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#56724): https://edk2.groups.io/g/devel/message/56724
Mute This Topic: https://groups.io/mt/72671870/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-