• Advertisement
Sign in to follow this  

Help with a small annoying memory bug in my function

This topic is 4904 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