2
0

Copy args so we can re-use it.

This commit is contained in:
Maarten Billemont 2017-08-29 12:06:40 -04:00
parent f5c7bee58f
commit 21a3a28980
2 changed files with 7 additions and 3 deletions

View File

@ -5,6 +5,6 @@ git:
submodules: true submodules: true
script: script:
- "( brew install libsodium json-c )" - "( brew install libsodium json-c )"
- "( cd ./platform-independent/cli-c && ./clean && targets='mpw mpw-bench mpw-tests' ./build && ./mpw-tests )" - "( cd ./platform-independent/cli-c && ./clean && targets='mpw mpw-bench mpw-tests' ./build && ./mpw-tests && ./mpw-cli-tests )"
- "( xcodebuild -workspace platform-darwin/MasterPassword.xcworkspace -configuration 'Test' -scheme 'MasterPassword iOS' -sdk iphonesimulator )" - "( xcodebuild -workspace platform-darwin/MasterPassword.xcworkspace -configuration 'Test' -scheme 'MasterPassword iOS' -sdk iphonesimulator )"
- "( xcodebuild -workspace platform-darwin/MasterPassword.xcworkspace -configuration 'Test' -scheme 'MasterPassword macOS' )" - "( xcodebuild -workspace platform-darwin/MasterPassword.xcworkspace -configuration 'Test' -scheme 'MasterPassword macOS' )"

View File

@ -360,11 +360,15 @@ const char *mpw_vstr(const char *format, va_list args) {
// TODO: Not thread-safe // TODO: Not thread-safe
static char *str_str; static char *str_str;
static size_t str_str_max; static size_t str_str_max;
if (!str_str && !(str_str = calloc( str_str_max = 1, 1 ))) if (!str_str && !(str_str = calloc( str_str_max = 1, sizeof( char ) )))
return NULL; return NULL;
do { do {
size_t len = (size_t)vsnprintf( str_str, str_str_max, format, args ); va_list args_attempt;
va_copy( args_attempt, args );
size_t len = (size_t)vsnprintf( str_str, str_str_max, format, args_attempt );
va_end( args_attempt );
if ((int)len < 0) if ((int)len < 0)
return NULL; return NULL;
if (len < str_str_max) if (len < str_str_max)