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 <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18267 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Liming Gao 2015-08-24 05:00:05 +00:00 committed by lgao4
parent c0f230ca75
commit 9023704f95
1 changed files with 1 additions and 0 deletions

View File

@ -717,6 +717,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH):
Index = Index + 1 Index = Index + 1
if Index == 1: if Index == 1:
AutoGenH.Append('\n#define __PCD_%s_VAL_CMP(GuidPtr) (' % (Pcd.TokenCName)) 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:' AutoGenH.Append('\\\n COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:'
% (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)) % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
else: else: