diff options
Diffstat (limited to 'third_party/re2/util/stringprintf.cc')
-rw-r--r-- | third_party/re2/util/stringprintf.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/third_party/re2/util/stringprintf.cc b/third_party/re2/util/stringprintf.cc index c908181..e71d9938 100644 --- a/third_party/re2/util/stringprintf.cc +++ b/third_party/re2/util/stringprintf.cc @@ -4,7 +4,7 @@ #include "util/util.h" -namespace re2 { +namespace re2 { static void StringAppendV(string* dst, const char* format, va_list ap) { // First try with a small fixed size buffer @@ -18,7 +18,7 @@ static void StringAppendV(string* dst, const char* format, va_list ap) { int result = vsnprintf(space, sizeof(space), format, backup_ap); va_end(backup_ap); - if ((result >= 0) && (result < sizeof(space))) { + if ((result >= 0) && (static_cast<unsigned long>(result) < sizeof(space))) { // It fit dst->append(space, result); return; @@ -38,7 +38,14 @@ static void StringAppendV(string* dst, const char* format, va_list ap) { // Restore the va_list before we use it again va_copy(backup_ap, ap); +#if !defined(_WIN32) result = vsnprintf(buf, length, format, backup_ap); +#else + // On Windows, the function takes five arguments, not four. With an array, + // the buffer size will be inferred, but not with a pointer. C'est la vie. + // (See https://github.com/google/re2/issues/40 for more details.) + result = vsnprintf(buf, length, _TRUNCATE, format, backup_ap); +#endif va_end(backup_ap); if ((result >= 0) && (result < length)) { |