I already made a project which is running fine. I copied a class of this project to other project which is creating problem.
Inside the class I have a structure like
struct Test{
CString m_path;
...
}
There is one function in class which returns the object of this structure like
Test& GetStructObj(){return m_strct;};
Somewhere in dialog class I am doing
test frImg = instImg.GetStructObj();
On this line exception is coming
Unhandled exception at 0x006cb4a8 in TestApp.exe: 0xC0000005: Access violation reading location 0xfffffff0.
I have seen in call stack exception comes at this function
static CStringData* __cdecl CloneData(_Inout_ CStringData* pData)
{
CStringData* pNewData = NULL;
IAtlStringMgr* pNewStringMgr = pData->pStringMgr->Clone();
Before this point call stack shows that at Copy constructor of structure Test, the CString data is coming as Bad pointer.
Disassembly shows this information
Engine::TestEdit::Test::Test:
006EF550 push ebp
006EF551 mov ebp,esp
006EF553 push 0FFFFFFFFh
006EF555 push offset __ehhandler$??0Image@ImageEdit@ImageEngine@@QAE@ABU012@@Z (0BCA3E8h)
006EF55A mov eax,dword ptr fs:[00000000h]
006EF560 push eax
006EF561 sub esp,0CCh
006EF567 push ebx
006EF568 push esi
006EF569 push edi
006EF56A push ecx
006EF56B lea edi,[ebp-0D8h]
006EF571 mov ecx,33h
006EF576 mov eax,0CCCCCCCCh
006EF57B rep stos dword ptr es:[edi]
006EF57D pop ecx
006EF57E mov eax,dword ptr [___security_cookie (0CEFD9Ch)]
006EF583 xor eax,ebp
006EF585 push eax
006EF586 lea eax,[ebp-0Ch]
006EF589 mov dword ptr fs:[00000000h],eax
006EF58F mov dword ptr [ebp-14h],ecx
006EF592 mov eax,dword ptr [ebp+8]
006EF595 push eax
006EF596 mov ecx,dword ptr [ebp-14h]
006EF599 call ATL::CStringT<wchar_t,StrTraitMFC<wchar_t,ATL::ChTraitsCRT<wchar_t> > >::CStringT<wchar_t,StrTraitMFC<wchar_t,ATL::ChTraitsCRT<wchar_t> > > (69D06Eh)
006EF59E mov dword ptr [ebp-4],0
I am totally wondered about the problem as the same class is working in other project but not working in this project.