[llvm] r211184 - Fix a memory leak in the error path.

David Blaikie dblaikie at gmail.com
Wed Jun 18 11:22:42 PDT 2014


On Wed, Jun 18, 2014 at 11:19 AM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
>> Is it possible to split this in to two APIs rather than a bool
>> parameter of "BufferOwned" & then use std::unique_ptr?
>
> Maybe, but I don't see why that would be better.  We would have to
> propagate the change up or callers would have to do
>
> if (BufferOwned)
>  return  createELFObjectFileOwned()
> else
>   return createELFObjectFile()

It would be better, I'd wager, because if you go far enough up -
you'll hopefuly find that each caller actually knows statically
whether it's owned or not, and this conditionality shouldn't be
required. But I haven't chased this far enough and I've spent a while
chatting to Lang about the issues around ownership of MemoryBuffers
and that it's a rather problematic API/usage.

- David

>
> The aux function makes it clear the buffer is deleted and allows for
> the runtime parameter.
>
> Cheers,
> Rafael




More information about the llvm-commits mailing list