Re: [PATCH] fmt-merge-msg: avoid leaking strbuf in shortlog()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 08.12.2017 um 19:44 schrieb Junio C Hamano:
> René Scharfe <l.s.r@xxxxxx> writes:
> 
>> Am 07.12.2017 um 22:27 schrieb Jeff King:
>>> Grepping for "list_append.*detach" shows a few other possible cases in
>>> transport-helper.c, which I think are leaks.
>>
>> -- >8 --
>> Subject: [PATCH] transport-helper: plug strbuf and string_list leaks
>>
>> Transfer ownership of detached strbufs to string_lists of the
>> duplicating variety by calling string_list_append_nodup() instead of
>> string_list_append() to avoid duplicating and then leaking the buffer.
>>
>> While at it make sure to release the string_list when done;
>> push_refs_with_export() already does that.
>>
>> Reported-by: Jeff King <peff@xxxxxxxx>
>> Signed-off-by: Rene Scharfe <l.s.r@xxxxxx>
>> ---
>>   transport-helper.c | 7 +++++--
>>   1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/transport-helper.c b/transport-helper.c
>> index bf05a2dcf1..f682e7c534 100644
>> --- a/transport-helper.c
>> +++ b/transport-helper.c
>> @@ -882,7 +882,8 @@ static int push_refs_with_push(struct transport *transport,
>>   			struct strbuf cas = STRBUF_INIT;
>>   			strbuf_addf(&cas, "%s:%s",
>>   				    ref->name, oid_to_hex(&ref->old_oid_expect));
>> -			string_list_append(&cas_options, strbuf_detach(&cas, NULL));
>> +			string_list_append_nodup(&cas_options,
>> +						 strbuf_detach(&cas, NULL));
>>   		}
>>   	}
>>   	if (buf.len == 0) {
>> @@ -897,6 +898,7 @@ static int push_refs_with_push(struct transport *transport,
>>   	strbuf_addch(&buf, '\n');
>>   	sendline(data, &buf);
>>   	strbuf_release(&buf);
>> +	string_list_release(&cas_options, 0);
> 
> There is no such function; you meant _clear() perhaps?

Yes, of course, I'm sorry.  Not sure what happened there. O_o

René



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux