[sheepdog] [PATCH] dog/farm/slice: fix memory leak in dog cluster snapshot load command

Ruoyu liangry at ucweb.com
Wed Apr 23 05:52:28 CEST 2014


On 2014年04月23日 11:23, Liu Yuan wrote:
> On Tue, Apr 22, 2014 at 05:04:04PM +0800, Ruoyu wrote:
>> Signed-off-by: Ruoyu <liangry at ucweb.com>
>> ---
>>   dog/farm/slice.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/dog/farm/slice.c b/dog/farm/slice.c
>> index 77db771..aaa61e9 100644
>> --- a/dog/farm/slice.c
>> +++ b/dog/farm/slice.c
>> @@ -102,6 +102,7 @@ void *slice_read(const unsigned char *sha1, size_t *outsize)
>>   
>>   	object = xmalloc(*outsize);
>>   	strbuf_copyout(&buf, object, *outsize);
>> +	free(file->slices);
>>   	free(file);
>>   	strbuf_release(&buf);
>>   	return object;
>> -- 
>> 1.8.3.2
> In error case, we should free(flie->slices) too.
Agree. In case of file->slices not allocated, we should check it first.
>
> Thanks
> Yuan





More information about the sheepdog mailing list