r207076 - Fix two leaks found by LSan.
Nico Weber
thakis at chromium.org
Wed Apr 23 22:52:15 PDT 2014
On Wed, Apr 23, 2014 at 10:39 PM, Chandler Carruth <chandlerc at google.com>wrote:
>
> On Wed, Apr 23, 2014 at 10:16 PM, Nico Weber <nicolasweber at gmx.de> wrote:
>
>> + if (DidSetDeprecatedMessage)
>> + clang_disposeString(*deprecated_message);
>> *deprecated_message =
>> cxstring::createDup(Deprecated->getMessage());
>> + DidSetDeprecatedMessage = true;
>>
>
> Can we really not tell that the message doesn't hold a string to dispose
> of? Maybe even better, have clang_disposeString just no-op in that case
> (the way free, delete, etc do)?
>
*deprecated_message is user-controlled, and there's no public api to
construct an empty CXString as far as I know.
A different approach would be to
if (deprecated_message)
*deprecated_message = cxstring::createNull();
at the beginning of the function, then it's possible to unconditionally
call clang_disposeString() – but it'd be a behavior change, since the
function would then set *deprecated_message to an empty string (instead of
not modifying it). I don't know how strict libclang is about behavior
changes.
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140423/6c807968/attachment.html>
More information about the cfe-commits
mailing list