aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/repeated_field.h
diff options
context:
space:
mode:
authorGravatar jieluo@google.com <jieluo@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2014-07-24 17:31:41 +0000
committerGravatar jieluo@google.com <jieluo@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2014-07-24 17:31:41 +0000
commit9eda53a6f1ab4229fd40473661d589be70382174 (patch)
treee4c2c4dd2d14bfb73811b7a8985313d86dd8ceec /src/google/protobuf/repeated_field.h
parente6726e2150d027f1cf4000f264adc8c7ec045f00 (diff)
Increase the allocated_size_ should be after allocation. Otherwise there might have segmentation fault if allocation throws an exception.
Diffstat (limited to 'src/google/protobuf/repeated_field.h')
-rw-r--r--src/google/protobuf/repeated_field.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h
index 1e9728ac..93d3cbba 100644
--- a/src/google/protobuf/repeated_field.h
+++ b/src/google/protobuf/repeated_field.h
@@ -897,8 +897,8 @@ inline typename TypeHandler::Type* RepeatedPtrFieldBase::Add() {
return cast<TypeHandler>(elements_[current_size_++]);
}
if (allocated_size_ == total_size_) Reserve(total_size_ + 1);
- ++allocated_size_;
typename TypeHandler::Type* result = TypeHandler::New();
+ ++allocated_size_;
elements_[current_size_++] = result;
return result;
}