Re: array new[] bug in Utils/StringUtils.cpp

Adrian Buehlmann <[email protected]>
Newsgroups gmane.comp.version-control.cvs.tortoisecvs.user
Message-ID <[email protected]>
On 22.06.2009 23:57, Torsten Martinsen wrote:
> Adrian Buehlmann wrote:
>> Hi all
>>
>> (this is intended for the TortoiseCVS developers, sorry if this is the wrong list
>> -- I haven't found a -devel list)
>>
>> We seem to have been taken the StringUtils.cpp of TortoiseCVS for TortoiseHg [1].
>>
>> I noticed there is an array new / delete bug in WideToMultibyte and MultibyteToWide
>> (new[] must be paired with delete[], which is not).
> You are correct, of course - auto_ptr is a poor choice in this case. I 
> would prefer boost::scoped_array, but since Boost is not a prerequisite 
> for TortoiseCVS, I will probably use another solution.

I've just taken std::vector, using ctor:

  vector(size_type n)

It is correct (it stores its elements in contiguous storage locations -- as required
by the standard), efficient enough, and part of std C++.

As a side note, I was surprised that I haven't seen any crashes or something. Maybe this
bug just doesn't manifest itself due to specific compiler / heap implementations (I used
MinGW and MS Visual C++ 8 and 9). Or maybe I haven't tried long enough :p

Thanks for sharing the sources, BTW!

Cheers,

Adrian

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.