-
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**********");
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
|