public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Guomin Jiang" <guomin.jiang@intel.com>
To: devel@edk2.groups.io
Cc: Michael D Kinney <michael.d.kinney@intel.com>,
	Liming Gao <liming.gao@intel.com>
Subject: [PATCH v4] MdePkg/UnitTestBaseLib: Add check for pointer BinData
Date: Tue, 24 Mar 2020 09:42:41 +0800	[thread overview]
Message-ID: <20200324014241.194-1-guomin.jiang@intel.com> (raw)

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2531

AllocatePool may fail and BinData may be invalid, check it before use.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
 MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
index 6f7c31cab4..8952f9da6c 100644
--- a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
+++ b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
@@ -252,9 +252,11 @@ RfcDecodeTest(
   BinSize = AsciiStrnLenS (binString, MAX_TEST_STRING_SIZE);
 
   BinData = AllocatePool (BinSize);
-  Btc->BufferToFree = BinData;
+  UT_ASSERT_NOT_NULL(BinData);
 
+  Btc->BufferToFree = BinData;
   ReturnSize = BinSize;
+
   Status = Base64Decode (b64String, b64StringLen, BinData, &ReturnSize);
 
   UT_ASSERT_STATUS_EQUAL (Status, Btc->ExpectedStatus);
-- 
2.25.1.windows.1


             reply	other threads:[~2020-03-24  1:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24  1:42 Guomin Jiang [this message]
2020-03-24 15:52 ` [PATCH v4] MdePkg/UnitTestBaseLib: Add check for pointer BinData Michael D Kinney
2020-03-24 17:38 ` [EXTERNAL] [edk2-devel] " Bret Barkelew

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200324014241.194-1-guomin.jiang@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox