]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Checked return value of malloc for EfiCompress.
authorYingke Liu <yingke.d.liu@intel.com>
Wed, 1 Jul 2015 05:16:46 +0000 (05:16 +0000)
committeryingke <yingke@Edk2>
Wed, 1 Jul 2015 05:16:46 +0000 (05:16 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yingke Liu <yingke.d.liu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17775 6f19259b-4bc3-4df7-8a09-765794883524

BaseTools/Source/C/Common/EfiCompress.c

index bd86d1276ad80e564a5f4e6d1f13c366b83d5a36..b225fee913bec3369eb4f92cd5137b36a85a59fd 100644 (file)
@@ -408,6 +408,9 @@ Returns:
   UINT32      i;\r
   \r
   mText       = malloc (WNDSIZ * 2 + MAXMATCH);\r
+  if (mText == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
   for (i = 0 ; i < WNDSIZ * 2 + MAXMATCH; i ++) {\r
     mText[i] = 0;\r
   }\r
@@ -418,6 +421,10 @@ Returns:
   mParent     = malloc (WNDSIZ * 2 * sizeof(*mParent));\r
   mPrev       = malloc (WNDSIZ * 2 * sizeof(*mPrev));\r
   mNext       = malloc ((MAX_HASH_VAL + 1) * sizeof(*mNext));\r
+  if (mLevel == NULL || mChildCount == NULL || mPosition == NULL ||\r
+    mParent == NULL || mPrev == NULL || mNext == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
   \r
   mBufSiz = 16 * 1024U;\r
   while ((mBuf = malloc(mBufSiz)) == NULL) {\r