This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix memory leak in cp-support.c (cp_canonicalize_string)


On 08/09/2017 12:40 PM, Yao Qi wrote:
> Alex Lindsay <alexlindsay239@gmail.com> writes:
> 
>> Formerly, in cp_canonicalize_string in cp-support.c, the return value of
>> cp_comp_to_string was never freed, creating a sizable memory leak detectable
>> with valgrind. This patch fixes the leak. However, a longer term solution
>> would be to change the return type of cp_comp_to_string to
>> gdb::unique_xmalloc_ptr<char>.
> 
> Hi Alex,
> Thanks a lot for the investigation and the patch.  I revise it a little
> to use gdb::unique_xmalloc_ptr<char>, and fix another leak somewhere else.
> Patch below is pushed in.
> 

Sorry about that, and thanks for the fix.

I think I'd be good if cp_comp_to_string was changed to
return a unique_ptr itself, to avoid similar cases creeping
back in.

As penance, I'll give it a try.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]