From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by mx.groups.io with SMTP id smtpd.web09.8915.1583389159144163742 for ; Wed, 04 Mar 2020 22:19:19 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ct8ym6oU; spf=pass (domain: gmail.com, ip: 209.85.210.193, mailfrom: newexplorerj@gmail.com) Received: by mail-pf1-f193.google.com with SMTP id z65so1744267pfz.8 for ; Wed, 04 Mar 2020 22:19:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=2Kt4vG08ndJ9EtFvReGo1uiNw0TVCLJGK8e1a0NbVLY=; b=Ct8ym6oU4CmX/ewwMVJXPjkBAVjljpKsBYMfcMxj3xKuHmc+kKCHRGo/nKzbW+wPmN lEEZlb8ziMjUfSg+Ujl7Zfdw/mHkWtiE/T6rsxYYQZPw4PmhVRx4a3xbb1/8I1xFLibl p1O1dtRc/q9Z5SZrGgvvKZgt+xqDVCeWhWGa/R1dujeIPBNBf4rx2QIz8s5jiX3OSmu0 0435RRRDZm5GxGUWNELrzenIQGDem67rTfJtASH+lWK2SXP1dXmJNtqV13y2zPgO0Qkd DuN2lIKWWfvysL2r196T8lYCp5kf0JrXny0eWSqIb23GxDGfiplc+iSGBnk+PpreVPdC cS2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2Kt4vG08ndJ9EtFvReGo1uiNw0TVCLJGK8e1a0NbVLY=; b=cmbrUr8dlxMwVF5xz0UVSquh9t3pSS5ubqiLm1u4KwddScH+7VC61ljqUnbLE2aEC3 Z1KZLPGsyU1UgbduJdFQstjTVZGIggQnxvMLynZMrCVP6ymf6aJeYJWgc1WVD4sX6hjQ SQwK8cJq6meMWlWI6vZji4Uz9nJXTmCch70gU/y+BMZD/p56N6pJl9e3v2hUPLaaqAU+ 8RjrWkQBeMsjflNes9sWLDR85l+K5eLLRTaev17+OTMb4P76Uj9YCR/cLk0zyFJZRH2F Z9Bkzs711pGKcuzr6jMdzDrULYYQEJfzIFaYYG1GJIgvMJi2uxkKeDGVPoMqC2wO3L29 CeNQ== X-Gm-Message-State: ANhLgQ1xLPczTlSyZ66FrwcFHbV04EAv3zu7kBWmr1DP1r+iQz0cEu8h cWr2oqRixGW84DG1x4aPRREgFzDiqzZAVw== X-Google-Smtp-Source: ADFU+vvHsAG+0srk45Qi4MgkY0JkkQt59pQdIr6lQpsAHMsYdhQkfa2ZauejYjwg6seySYp5VS56mw== X-Received: by 2002:a63:28c3:: with SMTP id o186mr6274839pgo.248.1583389158210; Wed, 04 Mar 2020 22:19:18 -0800 (PST) Return-Path: Received: from localhost.localdomain ([222.67.15.87]) by smtp.gmail.com with ESMTPSA id r13sm30203998pgf.1.2020.03.04.22.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 22:19:17 -0800 (PST) From: "GuoMinJ" To: devel@edk2.groups.io Cc: GuoMinJ , Michael D Kinney , Sean Brogan , Bret Barkelew Subject: [PATCH v2] UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use. Date: Thu, 5 Mar 2020 14:17:47 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2530 The Suite pointer is used before check if it is valid, correct it to check the validation before use. Cc: Michael D Kinney Cc: Sean Brogan Cc: Bret Barkelew Signed-off-by: GuoMinJ --- UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c | 6 +++--- UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c index fb247c59e7..b053e04959 100644 --- a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c @@ -33,13 +33,13 @@ RunTestSuite ( UNIT_TEST *Test; UNIT_TEST_FRAMEWORK *ParentFramework; - TestEntry = NULL; - ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework; - if (Suite == NULL) { return EFI_INVALID_PARAMETER; } + TestEntry = NULL; + ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework; + DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n")); DEBUG ((DEBUG_VERBOSE, "RUNNING TEST SUITE: %a\n", Suite->Title)); DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n")); diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c index fd15991ea4..b136992d99 100644 --- a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c @@ -436,7 +436,6 @@ AddTestCase ( Status = EFI_SUCCESS; Suite = (UNIT_TEST_SUITE *)SuiteHandle; - ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework; // // First, let's check to make sure that our parameters look good. @@ -445,6 +444,7 @@ AddTestCase ( return EFI_INVALID_PARAMETER; } + ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework; // // Create the new entry. NewTestEntry = AllocateZeroPool (sizeof( UNIT_TEST_LIST_ENTRY )); -- 2.17.1