| Index: third_party/re2/util/stringprintf.cc
|
| diff --git a/third_party/re2/util/stringprintf.cc b/third_party/re2/util/stringprintf.cc
|
| index c908181e56556fcdbb737c67930d1dd7f627e110..e71d993861f5da28d70816caaa62f18da9a574c9 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)) {
|
|
|