[PATCH libX11 4/5] fix memleak in error path

walter harms wharms at bfs.de
Tue Apr 26 15:45:45 UTC 2016



Am 26.04.2016 16:47, schrieb Eric Engestrom:
> On Tue, Apr 26, 2016 at 04:29:41PM +0200, walter harms wrote:
>>
>>
>> free all memory on error
>>
>> Signed-off-by: walter harms <wharms at bfs.de>
>>
>>
>> ---
>>  src/xlibi18n/lcPublic.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/xlibi18n/lcPublic.c b/src/xlibi18n/lcPublic.c
>> index 98a7435..08122b9 100644
>> --- a/src/xlibi18n/lcPublic.c
>> +++ b/src/xlibi18n/lcPublic.c
>> @@ -78,7 +78,7 @@ create(
>>      XLCdMethods methods)
>>  {
>>      XLCd lcd;
>> -    XLCdPublicMethods new;
>> +    XLCdPublicMethods new=NULL;
> 
> This is unnecessary: `new` will be overwritten a few lines below, or
> discarded as a local var if we return before that.
> 

leftover, but the whole new is useless as it is copied into
lcd->methods

>>
>>      lcd = Xcalloc(1, sizeof(XLCdRec));
>>      if (lcd == NULL)
>> @@ -97,6 +97,7 @@ create(
>>      return lcd;
>>
>>  err:
>> +    Xfree(lcd->core);
> 
> This bit is right though. Feel free to cleanup this patch & re-send.

stay tuned ..

re,
 wh

> 
>>      Xfree(lcd);
>>      return (XLCd) NULL;
>>  }
>> -- 
>> 2.1.4
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel


More information about the xorg-devel mailing list