Re: Stack around the variable 'v' was corrupted
"Jeffrey Walton" <noloader@gmail.com> wrote in message
news:b83b628a-eb54-4ec0-b3e8-0418b5feed3e@13g2000yql.googlegroups.com
CComPtr<Commands> pCommands;
CComPtr<IEnumVARIANT> pEnum;
hr = pCommands->_NewEnum( (IUnknown **)&pEnum );
This is effectively a downcast. Don't do this. Get an honest IUnknown*
pointer from _NewEnum, then QueryInterface from it to IEnumVARIANT.
ULONG fetched;
for( INT i = 1; i <= count; i++ )
{
CComVariant v;
hr = pEnum->Next( i, &v, &fetched );
The first parameter of IEnumXXX::Next determines how many elements you
request in a single call, not an index of the element as you seem to
believe. So on the second iteration you ask for two elements, but you
only provide space for one.
--
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