diff options
author | jieluo@google.com <jieluo@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2014-07-24 17:31:41 +0000 |
---|---|---|
committer | jieluo@google.com <jieluo@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2014-07-24 17:31:41 +0000 |
commit | 9eda53a6f1ab4229fd40473661d589be70382174 (patch) | |
tree | e4c2c4dd2d14bfb73811b7a8985313d86dd8ceec | |
parent | e6726e2150d027f1cf4000f264adc8c7ec045f00 (diff) | |
download | protobuf-9eda53a6f1ab4229fd40473661d589be70382174.tar.gz protobuf-9eda53a6f1ab4229fd40473661d589be70382174.tar.bz2 protobuf-9eda53a6f1ab4229fd40473661d589be70382174.zip |
Increase the allocated_size_ should be after allocation. Otherwise there might have segmentation fault if allocation throws an exception.
-rw-r--r-- | src/google/protobuf/repeated_field.h | 2 |
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; } |