Welcome to the Xceed Community | Help
Community Search  
More Search Options

Memory leak when using VC++ MFC.

Sort Posts: Previous Next
  •  10-10-2008, 11:00 AM Post no. 28472

    Memory leak when using VC++ MFC.

    COleVariant's assignment operator (operator '=') does not attach the variant to the instance, but rather makes a copy of the variant. Thus the following call is losing the returned variant, and vaData only holds (and will free) a copy of it:

    vaData = XceedEncryption.ReadFile ( _T ( "C:\\Test" ), 0, 0, efpDecrypt, TRUE, &ovBytesRead );

    To correctly use COleVariants, one must use its "Attach" method instead of its assignment operator, like this:

    vaData.Attach( XceedEncryption.ReadFile ( _T ( "C:\\Test" ), 0, 0, efpDecrypt, TRUE, &ovBytesRead ) );
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.