From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mx.groups.io with SMTP id smtpd.web12.2196.1605260842150915120 for ; Fri, 13 Nov 2020 01:47:22 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.35, mailfrom: xiewenyi2@huawei.com) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CXYXX27sRz76kh; Fri, 13 Nov 2020 17:47:08 +0800 (CST) Received: from HGH1000039998.huawei.com (10.184.68.188) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Fri, 13 Nov 2020 17:47:08 +0800 From: "wenyi,xie" To: CC: , , , , Subject: [PATCH EDK2 v1 1/1] BaseTools/VfrCompile: add NULL point check Date: Fri, 13 Nov 2020 17:45:47 +0800 Message-ID: <1605260747-55149-2-git-send-email-xiewenyi2@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1605260747-55149-1-git-send-email-xiewenyi2@huawei.com> References: <1605260747-55149-1-git-send-email-xiewenyi2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.184.68.188] X-CFilter-Loop: Reflected Content-Type: text/plain add NULL point check after allocating. Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen Signed-off-by: Wenyi Xie --- BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c b/BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c index 051ee4ec5d28..8c861d1542c6 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c +++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c @@ -1704,6 +1704,7 @@ char *s; require(ua!=NULL, "cannot allocate UserAction"); ua->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); + require(ua->action!=NULL, "cannot allocate action"); strcpy(ua->action, s); return ua; } @@ -1742,6 +1743,7 @@ int altnum; char *p; sprintf(buf, "_blk%d_alt%d", blockid, altnum); p = (char *)malloc(strlen(buf)+1); + require(expr,err)(expr,err)(p!=NULL, "cannot allocate buf"); strcpy(p, buf); return p; } -- 2.20.1.windows.1