From 9eda53a6f1ab4229fd40473661d589be70382174 Mon Sep 17 00:00:00 2001 From: "jieluo@google.com" Date: Thu, 24 Jul 2014 17:31:41 +0000 Subject: Increase the allocated_size_ should be after allocation. Otherwise there might have segmentation fault if allocation throws an exception. --- src/google/protobuf/repeated_field.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/google/protobuf/repeated_field.h') 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(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; } -- cgit v1.2.3