Memory leak when using VC++ MFC.
-
-
Xceed admin
-
-
-
Joined on 09-29-2008
-
Longueuil
-
Posts 443
-
-
|
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 ) ); |
|
|
|
|
|
|