From 2ff93494a7edff2b00eaaf0982de11420740be52 Mon Sep 17 00:00:00 2001 From: Sergio Campama Date: Fri, 22 Jul 2016 12:55:20 -0400 Subject: Fixes the parsing of the proto-framework map file. - Fixes memory issue where the pointer to the StringPiece would be allocated on the stack, and would mangle the output. - Fixes length of the file name when parsing the comma separated files. --- src/google/protobuf/compiler/objectivec/objectivec_file.cc | 2 +- src/google/protobuf/compiler/objectivec/objectivec_helpers.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/src/google/protobuf/compiler/objectivec/objectivec_file.cc index cf8c34e1..b864ef12 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_file.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_file.cc @@ -223,7 +223,7 @@ bool ImportWriter::ProtoFrameworkCollector::ConsumeLine( offset = proto_file_list.length(); } - StringPiece proto_file(proto_file_list, start, offset); + StringPiece proto_file(proto_file_list, start, offset - start); StringPieceTrimWhitespace(&proto_file); if (proto_file.size() != 0) { map::iterator existing_entry = diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc index 311bf35d..22c7a883 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc @@ -1306,7 +1306,8 @@ bool Parser::Finish() { return true; } // Force a newline onto the end to finish parsing. - p_ = StringPiece(leftover_ + "\n"); + leftover_ += "\n"; + p_ = StringPiece(leftover_); if (!ParseLoop()) { return false; } -- cgit v1.2.3