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

Re: Suboptimal and suspicious patterns using COM macros and functions

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: Tue, 11 Aug 2009 10:27:13 +0200

On 11.08.2009 09:30, Dmitry wrote:
> Hey.
>
> I was reading sources of TSVN (latest version) and stumbled upon two minor things:
>
> 1. In src\SubWCRev\Register.cpp and src\TortoiseShell\ItemIDList.cpp when checking HRESULT values the check is done like this: if( !SUCCEEDED( res ) ) {} . Instead FAILED macro could be used ( if ( FAILED( res ) ) {} ) - this would give exactly the same effect and more readable code.
>

Changed in r16889.

> 2. In src\TortoiseShell\ItemIDList.cpp near the end of ItemIDList::toString() method there's a condition:
> if (szDisplayName == NULL)
> {
> CoTaskMemFree(szDisplayName);
> return ret; //to avoid a crash!
> }
> The call to CoTaskMemFree() will have no effect if szDisplayName is NULL - this call only pollutes the code.

here, the if() clause is not because of CoTaskMemFree() but because the
next line
ret = szDisplayName;
would crash if szDisplayName is NULL (you can't assign NULL to an
std::string).

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=2382372
To unsubscribe from this discussion, e-mail: [dev-unsubscribe_at_tortoisesvn.tigris.org].
Received on 2009-08-11 10:27:50 CEST

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