From 9023704f95e4c3b4fc98a94c3b56936bad5ced0c Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Mon, 24 Aug 2015 05:00:05 +0000 Subject: BaseTools: Add NULL pointer check in AutoGen code 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 Reviewed-by: Star Zeng git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18267 6f19259b-4bc3-4df7-8a09-765794883524 --- 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 84bd607ea6..3afded6f65 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -717,6 +717,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): 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: -- cgit v1.2.3