[edk2-devel] [PATCH V2 1/2] MdeModulePkg/Variable: Initialize local variable "Variable"

Kubacki, Michael A michael.a.kubacki at intel.com
Thu Nov 21 23:02:35 UTC 2019


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

Fixes a new build warning in VS2012 introduced in f8ff4cca7c.

This patch initializes the local variable "Variable" in
VariableServiceGetNextVariableInternal ().

This ensures the pointers in the structure are initialized
in the case no variable stores exist in the list of variable
stores.

Cc: Liming Gao <liming.gao at intel.com>
Cc: Michael D Kinney <michael.d.kinney at intel.com>
Cc: Jian J Wang <jian.j.wang at intel.com>
Cc: Hao A Wu <hao.a.wu at intel.com>
Signed-off-by: Michael Kubacki <michael.a.kubacki at intel.com>
Reviewed-by: Liming Gao <liming.gao at intel.com>
Reviewed-by: Philippe Mathieu-Daude <philmd at redhat.com>
Reviewed-by: Jian J Wang <jian.j.wang at intel.com>
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c
index d458f1c608..f6d187543d 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c
@@ -551,6 +551,8 @@ VariableServiceGetNextVariableInternal (
     return EFI_INVALID_PARAMETER;
   }
 
+  ZeroMem (&Variable, sizeof (Variable));
+
   // Check if the variable exists in the given variable store list
   for (StoreType = (VARIABLE_STORE_TYPE) 0; StoreType < VariableStoreTypeMax; StoreType++) {
     if (VariableStoreList[StoreType] == NULL) {
-- 
2.16.2.windows.1


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

View/Reply Online (#51116): https://edk2.groups.io/g/devel/message/51116
Mute This Topic: https://groups.io/mt/61215201/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list