-
January 10th, 2009, 02:13 AM
#1
Run-Time Check Failure #2 - Stack around the variable was corrupted.
Hi All,
I have problem during execution of my program.
Error is Run-Time Check Failure #2 - Stack around the variable 'pwADErrBuff' was corrupted.
I increased variable pwADErrBuff size from 256 to 2048. But, still have problem.
Please help me in this,
Code Snippet is below,
WCHAR pwErrBuff[2048];
WCHAR pwADErrBuff[2048];
WCHAR * pADErrCodeStr;
pwErrBuff[0] = NULL;
pADErrCodeStr = CrackADError( passedhr);
int maxAlloc = sizeof(pwErrBuff)/sizeof(WCHAR);
// If an ADSI error code was returned, display it
if (pADErrCodeStr[0] != NULL)
{
SAFE_APPEND(maxAlloc, pwErrBuff, L"<*> ADSI Error HRESULT Returns: <*> \n");
SAFE_APPEND(maxAlloc, pwErrBuff, pADErrCodeStr);
SAFE_APPEND(maxAlloc, pwErrBuff, L"\n");
}
// Call ADsGetLastError() to retrieve the error text from ADSI
SAFE_APPEND(maxAlloc, pwErrBuff, L"<*> ADSI Error: <*>\n");
hr = ADsGetLastError(
&lError,
pwADErrBuff,
256,
L"",
0
);
if (FAILED(hr))
SAFE_APPEND(maxAlloc, pwErrBuff, L"<Unable to retrieve ADs Error>");
else
SAFE_APPEND(maxAlloc, pwErrBuff, pwADErrBuff);
SAFE_APPEND(maxAlloc, pwErrBuff, L"\n");
WCHAR sz[1024];
SAFE_APPEND(maxAlloc, pwErrBuff, L"<*> System Error: <*> \n");
// Check the standard system to crack the bad HRESULT into a string
if (!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, 0, passedhr, 0, sz, 1024, 0))
wcscat(sz, L"Unknown HRESULT error");
else
SAFE_APPEND(maxAlloc, pwErrBuff, sz);
// Display
OutputDebugStringW(pwErrBuff);
OutputDebugStringW(L"\r\n");
_putws(L"\n**********");
wprintf(L"\nERROR on %s\n\n",pwReason);
_putws(pwErrBuff);
printf("\nERROR on %X\n\n",passedhr);
_putws(L"\n**********");
-
January 10th, 2009, 02:20 AM
#2
Re: Run-Time Check Failure #2 - Stack around the variable was corrupted.
1) Please use code tags..go back and RE-READ the "BEfore you post" announcement if you have forgotten how.
2) The code does NOT look like (but it is hard to read without code tags!) C++/CLI [aka .NET] code. If it is NOT, then this is the WRONG forum, and need to ask a moderator to MOVE your thread (do NOT crate a duplicate, it simply creates more work for the moderator, who is already VOLUNTEERING (like the rest of us) his valuable time.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|