]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Add NULL pointer check in AutoGen code
authorLiming Gao <liming.gao@intel.com>
Mon, 24 Aug 2015 05:00:05 +0000 (05:00 +0000)
committerlgao4 <lgao4@Edk2>
Mon, 24 Aug 2015 05:00:05 +0000 (05:00 +0000)
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

BaseTools/Source/Python/AutoGen/GenC.py

index 84bd607ea6c04dc5ade534fc1821db58b756c380..3afded6f659cc78f2e34c6ba28a1f22fcd5401c0 100644 (file)
@@ -717,6 +717,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH):
                 Index = Index + 1\r
                 if Index == 1:\r
                     AutoGenH.Append('\n#define __PCD_%s_VAL_CMP(GuidPtr)  (' % (Pcd.TokenCName))\r
+                    AutoGenH.Append('\\\n  (GuidPtr == NULL) ? 0:')\r
                     AutoGenH.Append('\\\n  COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:' \r
                                     % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r
                 else:\r