Commit 9a84764
authored
Fix memory leak when adding the same key to the logger hash map multiple times (ros2#391)
The first time a key is added the hash map will retain a copy of the pointer and later will deallocate the memory during shutdown.
Subsequent times the same key is added to the hash map, it will NOT retain a copy of the new pointer, and hence not deallocate the
memory during shutdown.
This fixes the issue by checking if we're adding an entry for an existing key and if so, avoid allocating new memory.
Signed-off-by: Jacob Perron <jacob@openrobotics.org>1 parent c83c4c7 commit 9a84764
1 file changed
Lines changed: 14 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
771 | 771 | | |
772 | 772 | | |
773 | 773 | | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
781 | 788 | | |
782 | 789 | | |
783 | 790 | | |
| |||
0 commit comments