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

Help with a small annoying memory bug in my function

This topic is 5477 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 );

	// printing code follows here


Thanks for looking into this! Mark

Share this post

Link to post
Share on other sites
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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!