google/protobuf — pull request #43 by abuszta (2014-10-08 09:51:11+00:00)
Title: InitializeDefaultRepeatedFields() allocates memory but does not release ...

Using protobuf-2.6.0 and current master results in C++ example leakage in src/google/protobuf/extension_set.cc line 1632 and further.

This problem reproduces with current protobuf example:

```
valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all ./list_people_cpp database
```

Sample output:
```
...
==32205== 16 bytes in 1 blocks are still reachable in loss record 3 of 10
==32205== at 0x4C29180: operator new(unsigned long) (vg_replace_malloc.c:324)
==32205== by 0x4E8D146: google::protobuf::internal::InitializeDefaultRepeatedFields() (in /usr/lib/x86_64-linux-gnu/libprotobuf.so.9.0.0)
==32205== by 0x400E9F9: call_init.part.0 (dl-init.c:78)
==32205== by 0x400EAE2: call_init (dl-init.c:36)
==32205== by 0x400EAE2: _dl_init (dl-init.c:126)
==32205== by 0x40011C9: ??? (in /lib/x86_64-linux-gnu/ld-2.19.so)
...
```

It would be nice to have protobuf not leaving this memory unallocated to make good old memory sanitizer happy :).

One of the solutions would be creating destructor for StaticDefaultRepeatedFieldsInitializer which would clean everything. Another solution could be using unique pointers.