[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Patch: Wrong ownership sematics for BSTRs

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: Fri, 08 Jan 2010 18:57:49 +0100

On 08.01.2010 17:32, Dmitry wrote:
> Hey.
>
> Looking through TSVN code I've noticed the following pattern: CString::AllocSysString() is called and the returned value (raw BSTR) is passed as an "in" parameter to a COM call and not freed later. This makes BSTRs leak - noone takes ownership of the newly created BSTR. The same I guess applies to SafeArrayPutElement() - MSDN (http://msdn.microsoft.com/en-us/library/ms891261.aspx) says "If the data element is a string<skipped> the function copies it correctly." which implies that a new BSTR is created and owned by the array and the BSTR returned by CString::AllocSysString() is leaked.
>
> A patch is proposed - it uses CComBSTR to manage BSTRs lifetime and addresses some other minor issues.

too many compiler errors to get committed.

Stefan

-- 
        ___
   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.net
------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2435812
To unsubscribe from this discussion, e-mail: [dev-unsubscribe_at_tortoisesvn.tigris.org].
Received on 2010-01-08 18:58:20 CET

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.