Commit 9eda53a6 authored by jieluo@google.com's avatar jieluo@google.com

Increase the allocated_size_ should be after allocation. Otherwise there might…

Increase the allocated_size_ should be after allocation. Otherwise there might have segmentation fault if allocation throws an exception.
parent e6726e21
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment