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

wenyi,xie via groups.io xiewenyi2=huawei.com at groups.io
Tue Nov 17 01:49:32 UTC 2020


Hi Liming,

I get it and agree with you, since it's just found by code review.

Thanks
Wenyi

On 2020/11/16 23:51, gaoliming wrote:
> Wenyi:
>   Do you meet with the real problem in VfrCompile? Or just find them by code
> review. 
>   Pccts is from the third party code. If no obvious reason, I don't prefer
> to change it. 
> 
> Thanks
> Liming
>> -----邮件原件-----
>> 发件人: Wenyi Xie <xiewenyi2 at huawei.com>
>> 发送时间: 2020年11月13日 17:46
>> 收件人: devel at edk2.groups.io
>> 抄送: bob.c.feng at intel.com; gaoliming at byosoft.com.cn;
>> yuwei.chen at intel.com; songdongkuang at huawei.com;
>> xiewenyi2 at huawei.com
>> 主题: [PATCH EDK2 v1 1/1] BaseTools/VfrCompile: add NULL point check
>>
>> 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 (#67632): https://edk2.groups.io/g/devel/message/67632
Mute This Topic: https://groups.io/mt/78294723/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