For DynamicEx PCD, if NULL pointer is specified as token space GUID,
it will directly be used to compare GUID value in AutoGen code.
To avoid access NULL pointer, NULL pointer will be checked first.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <[email protected]>
---
 BaseTools/Source/Python/AutoGen/GenC.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index b76d315..66756a3 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -715,10 +715,11 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH):
         for Pcd in PcdExList:
             if Pcd.Type in gDynamicExPcd and Pcd.TokenCName == TokenCName:
                 Index = Index + 1
                 if Index == 1:
                     AutoGenH.Append('\n#define __PCD_%s_VAL_CMP(GuidPtr)  (' % 
(Pcd.TokenCName))
+                    AutoGenH.Append('\\\n  (GuidPtr == NULL) ? 0:')
                     AutoGenH.Append('\\\n  COMPAREGUID (GuidPtr, &%s) ? 
_PCD_TOKEN_%s_%s:' 
                                     % (Pcd.TokenSpaceGuidCName, 
Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
                 else:
                     AutoGenH.Append('\\\n  COMPAREGUID (GuidPtr, &%s) ? 
_PCD_TOKEN_%s_%s:' 
                                     % (Pcd.TokenSpaceGuidCName, 
Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
-- 
1.9.5.msysgit.0

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to