[edk2-devel] [PATCH EDK2 v1 1/1] BaseTools/VfrCompile: add NULL point check

wenyi,xie via groups.io xiewenyi2=huawei.com at groups.io
Fri Nov 13 09:45:47 UTC 2020


add NULL point check after allocating.

Cc: Bob Feng <bob.c.feng at intel.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen at intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2 at huawei.com>
---
 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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#67524): https://edk2.groups.io/g/devel/message/67524
Mute This Topic: https://groups.io/mt/78226425/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list