Skip to content

Commit

Permalink
Merge pull request opencv#709 from taka-no-me:cv_format
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Kamaev authored and OpenCV Buildbot committed Mar 26, 2013
2 parents 6e2708e + 2107ea9 commit 8eff34e
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions modules/core/src/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,23 @@ const String& getBuildInformation()

String format( const char* fmt, ... )
{
char buf[1 << 16];
va_list args;
va_start( args, fmt );
vsprintf( buf, fmt, args );
return String(buf);
char buf[1024];

va_list va;
va_start(va, fmt);
int len = vsnprintf(buf, sizeof(buf), fmt, va);
va_end(va);

if (len >= (int)sizeof(buf))
{
String s(len, '\0');
va_start(va, fmt);
len = vsnprintf((char*)s.c_str(), len + 1, fmt, va);
va_end(va);
return s;
}

return String(buf, len);
}

String tempfile( const char* suffix )
Expand Down

0 comments on commit 8eff34e

Please sign in to comment.