Crash in Empty() function of CComBSTR

Verrouillé Crash in Empty() function of CComBSTR

  • lundi 7 mai 2012 07:11
     
     

    We have some legacy MFC where CComBSTR is used a lot. Of late I have seen it crash in CComBSTR::Empty() function on some machines. This is in VS 2003 and has worked in the same environment for many years.

    Any guidance about precautions to be maintained in its usage would be useful

Toutes les réponses

  • lundi 7 mai 2012 16:17
     
     
    Try showing a self-contained example which reproduces the problem.
  • jeudi 17 mai 2012 18:45
     
     
    This can happen if you pass a CComBSTR instance from one module (.exe, .dll) to another that is using a different heap manager (e.g. when the module is built with static linking).  Could this be what is happening?
     
    -- David
     

    Efficiently read and post to forums with newsreaders: http://communitybridge.codeplex.com
  • vendredi 18 mai 2012 00:49
     
     

    On 5/17/2012 2:45 PM, David Ching [MVP] wrote:

    This can happen if you pass a CComBSTR instance from one module (.exe, .dll) to another that is using a different heap manager (e.g. when the module is built with static linking).  Could this be what is happening?

    If used correctly, the memory that CComBSTR manages would be allocated by SysAllocString et al, using the OS-provided heap manager. It should be safe to pass between modules - in fact, that's the whole point of BSTR.--
    Igor Tandetnik