Jump to content
  • Advertisement
Sign in to follow this  
Mark Tanner

Help with a small annoying memory bug in my function

This topic is 5114 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have got a custom print function, it works but I sometimes get a warning from memory checking software like Purify or BoundsChecker: 'Uninitialized memory read' at wvsprintf( buffer, fmt, arglist ); I get it when I call the function below with only one argument, for example: CustomPrint( "gamedev" ); How can I avoid this? I just want a function I can call with a variable argument list, like: CustomPrint( "error in: %d", line ); Here's the function:
void CustomPrint( const char *fmt, ... )
{	
	// Format string
	char buffer[256];
	va_list arglist;
	va_start( arglist, fmt );
	wvsprintf( buffer, fmt, arglist );
	va_end(arglist);

	// printing code follows here

}

Thanks for looking into this! Mark

Share this post


Link to post
Share on other sites
Advertisement
i don't know how wvsprintf works, but can guess it isn't safe at all and can cause buffer overflow, result is not guaranteed to be zero-terminated, etc ... so if you use it, why worry about warnings?

anyway, it's probably because buffer is uninitialized and send as `parameter' to wvsprintf

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!