public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v4] MdePkg/UnitTestBaseLib: Add check for pointer BinData
@ 2020-03-24  1:42 Guomin Jiang
  2020-03-24 15:52 ` Michael D Kinney
  2020-03-24 17:38 ` [EXTERNAL] [edk2-devel] " Bret Barkelew
  0 siblings, 2 replies; 3+ messages in thread
From: Guomin Jiang @ 2020-03-24  1:42 UTC (permalink / raw)
  To: devel; +Cc: Michael D Kinney, Liming Gao

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-24 17:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-24  1:42 [PATCH v4] MdePkg/UnitTestBaseLib: Add check for pointer BinData Guomin Jiang
2020-03-24 15:52 ` Michael D Kinney
2020-03-24 17:38 ` [EXTERNAL] [edk2-devel] " Bret Barkelew

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox