aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/cpp/cpp_service.cc
diff options
context:
space:
mode:
authorBo Yang <teboring@google.com>2016-06-07 11:49:40 -0700
committerBo Yang <teboring@google.com>2016-06-07 14:15:07 -0700
commitb60e615cba2131490c4b42d2b03de057407226d1 (patch)
treec301623ffacedcda2f179c022911a61536341a78 /src/google/protobuf/compiler/cpp/cpp_service.cc
parent6aa981f94975d8619552d7f709632a79a1680e4f (diff)
downloadprotobuf-b60e615cba2131490c4b42d2b03de057407226d1.tar.gz
protobuf-b60e615cba2131490c4b42d2b03de057407226d1.tar.bz2
protobuf-b60e615cba2131490c4b42d2b03de057407226d1.zip
Fix the undefined behavior for opensource users.
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_service.cc')
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_service.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_service.cc b/src/google/protobuf/compiler/cpp/cpp_service.cc
index 226c2aa0..6030f7ce 100644
--- a/src/google/protobuf/compiler/cpp/cpp_service.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_service.cc
@@ -298,13 +298,15 @@ void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
" return $type$::default_instance();\n");
}
- printer->Print(vars_,
+ printer->Print(
" default:\n"
" GOOGLE_LOG(FATAL) << \"Bad method index; this should never happen.\";\n"
- " return *static_cast< ::google::protobuf::Message*>(NULL);\n"
+ " return *::google::protobuf::MessageFactory::generated_factory()\n"
+ " ->GetPrototype(method->$input_or_output$_type());\n"
" }\n"
"}\n"
- "\n");
+ "\n",
+ "input_or_output", which == REQUEST ? "input" : "output");
}
void ServiceGenerator::GenerateStubMethods(io::Printer* printer) {