Skip to content

Commit

Permalink
Fix the memory leak of GetEmptyString().
Browse files Browse the repository at this point in the history
  • Loading branch information
xfxyjwf committed Oct 9, 2014
1 parent 0971bb0 commit 06e6690
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/google/protobuf/generated_message_util.cc
Expand Up @@ -36,7 +36,6 @@

#include <limits>


namespace google {
namespace protobuf {
namespace internal {
Expand All @@ -51,8 +50,13 @@ double NaN() {
const ::std::string* empty_string_;
GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_);

void DeleteEmptyString() {
delete empty_string_;
}

void InitEmptyString() {
empty_string_ = new string;
OnShutdown(&DeleteEmptyString);
}


Expand Down

0 comments on commit 06e6690

Please sign in to comment.