aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Paul Yang <TeBoring@users.noreply.github.com>2015-06-30 16:45:22 -0700
committerGravatar Paul Yang <TeBoring@users.noreply.github.com>2015-06-30 16:45:22 -0700
commiteb162dad5f4b56dead4fa593e99eaef1b5440bb1 (patch)
tree1b42b9ea635701806d23c11150044793d5c7b65b /src
parentc3cb53b8f46d2909ae9fe3d9488fc915bcf453fb (diff)
parent37df4b65a473ce10843aa94e3fb5867e72d8df73 (diff)
Merge pull request #458 from xfxyjwf/memory_leak
Delete default UnknownFieldSet when shuting down.
Diffstat (limited to 'src')
-rw-r--r--src/google/protobuf/unknown_field_set.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/google/protobuf/unknown_field_set.cc b/src/google/protobuf/unknown_field_set.cc
index 76644900..93f0f206 100644
--- a/src/google/protobuf/unknown_field_set.cc
+++ b/src/google/protobuf/unknown_field_set.cc
@@ -50,8 +50,13 @@ namespace {
// instantiate the UnknownFieldSet dynamically only when required.
UnknownFieldSet* default_unknown_field_set_instance_ = NULL;
+void DeleteDefaultUnknownFieldSet() {
+ delete default_unknown_field_set_instance_;
+}
+
void InitDefaultUnknownFieldSet() {
default_unknown_field_set_instance_ = new UnknownFieldSet();
+ internal::OnShutdown(&DeleteDefaultUnknownFieldSet);
}
GOOGLE_PROTOBUF_DECLARE_ONCE(default_unknown_field_set_once_init_);