From aa779cd779b660e3e4f6560519827bfb15a7b488 Mon Sep 17 00:00:00 2001 From: Samuel Benzaquen Date: Fri, 25 Feb 2022 14:10:34 -0500 Subject: [PATCH 1/2] Update protoc-gen-upb.cc --- upbc/protoc-gen-upb.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/upbc/protoc-gen-upb.cc b/upbc/protoc-gen-upb.cc index 3eb2946bb9..def169f91c 100644 --- a/upbc/protoc-gen-upb.cc +++ b/upbc/protoc-gen-upb.cc @@ -1493,10 +1493,14 @@ bool Generator::Generate(const protobuf::FileDescriptor* file, } } - Output h_output(context->Open(HeaderFilename(file))); + std::unique_ptr h_output_stream( + context->Open(HeaderFilename(file))); + Output h_output(h_output_stream.get()); WriteHeader(file, h_output); - Output c_output(context->Open(SourceFilename(file))); + std::unique_ptr c_output_stream( + context->Open(SourceFilename(file))); + Output c_output(c_output_stream.get()); WriteSource(file, c_output, fasttable_enabled); return true; From 8d755661aa3f5a4894051b418ce03aea90916e36 Mon Sep 17 00:00:00 2001 From: Samuel Benzaquen Date: Fri, 25 Feb 2022 14:11:03 -0500 Subject: [PATCH 2/2] Update protoc-gen-upbdefs.cc --- upbc/protoc-gen-upbdefs.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/upbc/protoc-gen-upbdefs.cc b/upbc/protoc-gen-upbdefs.cc index a5e07560fb..51b3b95927 100644 --- a/upbc/protoc-gen-upbdefs.cc +++ b/upbc/protoc-gen-upbdefs.cc @@ -170,10 +170,14 @@ bool Generator::Generate(const protobuf::FileDescriptor* file, return false; } - Output h_def_output(context->Open(DefHeaderFilename(file->name()))); + std::unique_ptr h_output_stream( + context->Open(DefHeaderFilename(file->name()))); + Output h_def_output(h_output_stream.get()); WriteDefHeader(file, h_def_output); - Output c_def_output(context->Open(DefSourceFilename(file->name()))); + std::unique_ptr c_output_stream( + context->Open(DefSourceFilename(file->name()))); + Output c_def_output(c_output_stream.get()); WriteDefSource(file, c_def_output); return true;