Add NULL pointer check.

Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14084 6f19259b-4bc3-4df7-8a09-765794883524
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 2c980b3..8f10425 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -1496,6 +1496,7 @@
                    );

         if (!EFI_ERROR (Status)) {

           if (!Variable->Volatile) {

+            ASSERT (CacheVariable->InDeletedTransitionPtr != NULL);

             CacheVariable->InDeletedTransitionPtr->State = State;

           }

         } else {

@@ -1824,6 +1825,7 @@
                  );

       if (!EFI_ERROR (Status)) {

         if (!Variable->Volatile) {

+          ASSERT (CacheVariable->InDeletedTransitionPtr != NULL);

           CacheVariable->InDeletedTransitionPtr->State = State;

         }

       } else {

diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
index c70b467..123ce6f 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
@@ -1763,6 +1763,7 @@
                    );

         if (!EFI_ERROR (Status)) {

           if (!Variable->Volatile) {

+            ASSERT (CacheVariable->InDeletedTransitionPtr != NULL);

             CacheVariable->InDeletedTransitionPtr->State = State;

           }

         } else {

@@ -2185,6 +2186,7 @@
                  );

       if (!EFI_ERROR (Status)) {

         if (!Variable->Volatile) {

+          ASSERT (CacheVariable->InDeletedTransitionPtr != NULL);

           CacheVariable->InDeletedTransitionPtr->State = State;

         }

       } else {