[Opengc-devel] Debug-mode failure when built with VC7
Status: Pre-Alpha
Brought to you by:
madmartigan
From: Tim C. <tim...@ge...> - 2004-04-26 17:30:35
|
Hello: I have been building the OpenGC code under Microsoft Visual Studio .NET (Version 7). I am building the Debug target. When I run it under the debugger, I get frequent run-time error checks saying that the stack frame is corrupted around the variable "buffer". An example of this can be found in ogcBoeing777SpeedTape.cpp, ogcBoeing777SpeedTape::Render, which declares char buffer[1]; and has many lines that look like this: sprintf( buffer, "%i", charSpd/100); Even when the result of (charSpd/100) is one digit, sprintf is null-terminating the string that it is writing to. This is resulting in a desired write to &(Buffer[0]), but also an undesired write to &(Buffer[0])+1. I believe this is what the MSVC debugger is complaining about, since it puts guard data around each variable on the stack, and detects corruption of that guard data. To confirm this, and modified the declaration of Buffer to look like this: char buffer[2]; and modified the sprintf code to look like this: buffer[1] = 255; sprintf( buffer, "%i", charSpd/100); After stepping over the sprintf, sure enough buffer[1] is zero. Tim Crews GECO, Inc Mesa, Arizona, USA |