Sign in to follow this  
Mark Tanner

Help with a small annoying memory bug in my function

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this