Index: third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc |
diff --git a/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc b/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc |
index 97b73b88e77915474604ce19bcc728461882b23e..b3a71ce31d104003f32a9b2977c963b4f84797b3 100644 |
--- a/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc |
+++ b/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc |
@@ -1,6 +1,6 @@ |
// Protocol Buffers - Google's data interchange format |
// Copyright 2008 Google Inc. All rights reserved. |
-// https://developers.google.com/protocol-buffers/ |
+// http://code.google.com/p/protobuf/ |
// |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
@@ -33,14 +33,11 @@ |
// Sanjay Ghemawat, Jeff Dean, and others. |
#include <google/protobuf/io/zero_copy_stream_impl_lite.h> |
- |
-#include <algorithm> |
-#include <limits> |
- |
-#include <google/protobuf/stubs/casts.h> |
#include <google/protobuf/stubs/common.h> |
#include <google/protobuf/stubs/stl_util.h> |
+#include <algorithm> |
+ |
namespace google { |
namespace protobuf { |
namespace io { |
@@ -164,23 +161,15 @@ bool StringOutputStream::Next(void** data, int* size) { |
// without a memory allocation this way. |
STLStringResizeUninitialized(target_, target_->capacity()); |
} else { |
- // Size has reached capacity, try to double the size. |
- if (old_size > std::numeric_limits<int>::max() / 2) { |
- // Can not double the size otherwise it is going to cause integer |
- // overflow in the expression below: old_size * 2 "; |
- GOOGLE_LOG(ERROR) << "Cannot allocate buffer larger than kint32max for " |
- << "StringOutputStream."; |
- return false; |
- } |
- // Double the size, also make sure that the new size is at least |
- // kMinimumSize. |
+ // Size has reached capacity, so double the size. Also make sure |
+ // that the new size is at least kMinimumSize. |
STLStringResizeUninitialized( |
target_, |
max(old_size * 2, |
kMinimumSize + 0)); // "+ 0" works around GCC4 weirdness. |
} |
- *data = mutable_string_data(target_) + old_size; |
+ *data = string_as_array(target_) + old_size; |
*size = target_->size() - old_size; |
return true; |
} |