[OpenWrt-Devel] [LEDE-DEV] [PATCH libubox 1/3] Fix various memory management issues

Matthias Schiffer mschiffer at universe-factory.net
Tue Jun 21 11:10:27 EDT 2016


On 06/21/2016 12:32 PM, Jo-Philipp Wich wrote:
> Hi,
> 
> first of all, thanks for putting work into that - I like the changes in
> general. Have a few comments inline below.
> 
> ~ Jo
> 
[...]
>> diff --git a/lua/uloop.c b/lua/uloop.c
>> index 782b5a5..db89e72 100644
>> --- a/lua/uloop.c
>> +++ b/lua/uloop.c
>> @@ -325,9 +325,12 @@ static int ul_process(lua_State *L)
>>  		int argn = lua_objlen(L, -3);
>>  		int envn = lua_objlen(L, -2);
>>  		char** argp = malloc(sizeof(char*) * (argn + 2));
>> -		char** envp = malloc(sizeof(char*) * envn + 1);
>> +		char** envp = malloc(sizeof(char*) * (envn + 1));
>>  		int i = 1;
>>  
>> +		if (!argp || !envp)
>> +			exit(-1);
> 
> A "return luaL_error(L, "Out of memory");" might be slightly more
> appropriate here.

This one is actually in the forked process. I'll change it from exit() to
_exit() to avoid affecting resources used by the parent process (and also
adjust the exit() a few lines below). I don't think it would be appropriate
to raise a Lua error in the child process.

Matthias

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20160621/b0386604/attachment.sig>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list