[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Check malloc result in getopt_long
From: |
Pádraig Brady |
Subject: |
Re: [PATCH] Check malloc result in getopt_long |
Date: |
Wed, 18 Feb 2015 03:50:15 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
On 16/02/15 21:55, Tobias Stoeckmann wrote:
> On Mon, Feb 16, 2015 at 08:57:00PM +0000, Pádraig Brady wrote:
>> I'm not sure it's generally worth proceeding in OOM conditions
>> unless there are clear fall backs. It would be nice to depend on xalloc
>> and just call xmalloc(). Could this suffice?
>>
>> #ifdef _LIBC
>> struct option_list *newp = alloca (sizeof (*newp));
>> #else
>> struct option_list *newp = xmalloc (sizeof (*newp));
>> #endif
>
> Yeah, I am fine with that solution.
> Didn't think about simply using xmalloc there. Maybe it was too easy. :)
We can't use xmalloc for licensing reasons.
Anyway it's better for this lib to fall back to a degraded diagnostic than exit.
Also I noticed a mem leak in the non mem exhaustion case.
Hopefully the attached addresses all this.
thanks,
Pádraig.
getopt-mem-exhaustion.patch
Description: Text Data