You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Make snprintf available on Windows:
// Don’t ever do this! These two functions are different!
#define snprintf _snprintf
(the former 0-terminates if the printed string is larger than the size, the latter doesn't.)
Audit calls to snprintf, check lack of 0-termination isn't an issue, then either have a portable wrapper around _snprintf on windows (that writes 0 in the last entry always), or something else.
The text was updated successfully, but these errors were encountered:
I think I was avoiding making a std::string StringPrintf(...) function just out of laziness. I am pretty sure we're not using format strings in any place where perf critical where we care about extra allocs or whatever.
(My new favorite trick to use, instead of sprintf(buf, "%s:%d blah", x, y), is instead std::string Fmt(const char* fmt, Arg arg1=Arg::None, Arg arg2=Arg::None) which is used like Fmt("$:$ blah", x, y) and Arg has implicit ctors for the various types you care about. Not that Ninja needs this.)
http://randomascii.wordpress.com/2013/04/03/stop-using-strncpy-already/ :
(the former 0-terminates if the printed string is larger than the size, the latter doesn't.)
Audit calls to snprintf, check lack of 0-termination isn't an issue, then either have a portable wrapper around _snprintf on windows (that writes 0 in the last entry always), or something else.
The text was updated successfully, but these errors were encountered: