Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-Time Debug Error: "DAMAGE: after Normal block.... "

Status
Not open for further replies.

zer0FX

Programmer
Jan 14, 2003
5
CA
Hello,

I am getting a run-time debug error of the following type:

DAMAGE: after Normal block (#XXX) at 0xXXXXXXXX

It seems to be related to the KB article Q172398 - BUG: Debug Assertion When Assigning to STL string. However, I cannot use this fix as I am not using strings, but a buffer of characters, so I cannot call strvar.erase(). Here is the code that eventually causes the error:

if (GetClientRect(appGetWnd(), &lpRect))
{
width = lpRect.right - lpRect.left;
height = lpRect.bottom - lpRect.top;

acBuffer = (unsigned char *) malloc(width*height*PIXEL_COMPONENTS);

ScreenShot(0, 0, width, height, GL_BGR_EXT, GL_UNSIGNED_BYTE, acBuffer);
WriteTGA("Screenshot.tga", width, height, acBuffer);

free(acBuffer);
}

You can see that the size of the buffer changes whenever the window has been resized.

I have searched through Google and have not found anything that helps me out. Any input as to how to solve this problem would be greatly appreciated.

--zer0FX
 
acBuffer = (unsigned char *) malloc(width*height*PIXEL_COMPONENTS);

ScreenShot(0, 0, width, height, GL_BGR_EXT, GL_UNSIGNED_BYTE, acBuffer);


No idea what PIXEL_COMPONENTS is ?
No idea what ScreenShot() is ?



-pete
I just can't seem to get back my IntelliSense
 
Just a wild guess :

Could it be that witdth = right - left + 1 ? (And height = bottom - top + 1)

/JOlesen
 
You might wnat to debug your code to see if nothing gets written beyond the allocated block of memory. I've never seen any other reason for the error you're getting (and it probably does this when freeing the block).....


Greetings,
Rick
 
In response to palbano, to clarify some of the code:

PIXEL_COMPONENTS = 3 (I am reading an R, G, and B component from each pixel.

ScreenShot() is a wrapper function that for the moment is calling glReadPixels() directly with the same parameters.

......

I found out what the problem was, I had not set the PACK_ALIGNMENT parameter properly for the glReadPixels so the function was overwriting its bounds.

zer0FX
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top