Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: third_party/re2/util/stringprintf.cc

Issue 1516543002: Update re2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated update instructions Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/re2/util/stringpiece.cc ('k') | third_party/re2/util/strutil.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)) {
« no previous file with comments | « third_party/re2/util/stringpiece.cc ('k') | third_party/re2/util/strutil.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698