|
|
|
date: Sun, 19 Aug 2007 14:55:32 +0100,
group: microsoft.public.platformsdk.com_ole
back
Re: Problems using CComBSTR.
"Mark Gillespie" wrote in message
news:op.txa7mu2ij2q9yy@xplaptop.draytek
> Hi,l I have a problem, where my debug builds are working, but in
> release comfiguration, my appliction crashes when I create a CComBSTR
> object.
> I don't need to do much to make it crash, the following code always
> fails for me..
>
> CoInitialize(NULL);
> CComBSTR MyString( "Apples" );
>
>
> Now I know the Coinitialise suceeds, why should I not be able to
> create a CComBSTR? And why the difference between debug and release?
Most likely, you are corrupting the heap in some other, possibly
completely unrelated, piece of code. E.g. a buffer overrun in a
dynamically allocated array. When this happens, the problem manifests
only when some later allocation accidentally happens to hit corrupted
data structures.
The difference between a debug and release build is that in debug build,
a memory allocation request adds some padding around the allocated
buffer, precisely to detect buffer overruns when the memory is freed.
But, while it's not yet freed, a small overrun does not break the
program in debug build the way it does in release.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
date: Sun, 19 Aug 2007 11:53:09 -0400
author: Igor Tandetnik
|
|