diff options
author | kcgen <kcgen@users.noreply.github.com> | 2022-10-14 02:13:36 +0300 |
---|---|---|
committer | kcgen <1557255+kcgen@users.noreply.github.com> | 2022-10-14 05:18:46 +0300 |
commit | dfb8ef5e6a4a62c9ef116d750e907dc9064c88cf (patch) | |
tree | 7142533abe22dcd7fe4e32a8df61e59d465f969b /src | |
parent | 4282def0e464406d9ffee0dc778565e8ade188a8 (diff) |
Fix a memory leak in TalChorus
Fixes:
Direct leak of 128 byte(s) in 1 object(s) allocated from:
#0 0x55c7a8a80b3d in operator new(unsigned long) (/usr/src/dosbox-staging/build/clang-both-a_u/dosbox+0x1358b3d) (BuildId: 09f4c46c22a1b04de8e13e427d9d203a3193c043)
#1 0x55c7aa68ddee in ChorusEngine::setUpChorus(float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/ChorusEngine.h:80:19
#2 0x55c7aa647b40 in ChorusEngine::ChorusEngine(float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/ChorusEngine.h:55:9
#3 0x55c7aa645879 in __cxx_global_var_init /usr/src/dosbox-staging/build/clang-both-a_u/../../src/hardware/mixer.cpp:149:31
#4 0x55c7aa645b34 in _GLOBAL__sub_I_mixer.cpp /usr/src/dosbox-staging/build/clang-both-a_u/../../src/hardware/mixer.cpp
#5 0x7f173ff10eba in call_init csu/../csu/libc-start.c:145:3
#6 0x7f173ff10eba in __libc_start_main csu/../csu/libc-start.c:379:5
Indirect leak of 5224 byte(s) in 1 object(s) allocated from:
#0 0x55c7a8a80b3d in operator new(unsigned long) (/usr/src/dosbox-staging/build/clang-both-a_u/dosbox+0x1358b3d) (BuildId: 09f4c46c22a1b04de8e13e427d9d203a3193c043)
#1 0x55c7aa68e1ca in Chorus::Chorus(float, float, float, float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/Chorus.h:76:7
#2 0x55c7aa68ded3 in ChorusEngine::setUpChorus(float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/ChorusEngine.h:81:23
#3 0x55c7aa647b40 in ChorusEngine::ChorusEngine(float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/ChorusEngine.h:55:9
#4 0x55c7aa645879 in __cxx_global_var_init /usr/src/dosbox-staging/build/clang-both-a_u/../../src/hardware/mixer.cpp:149:31
#5 0x55c7aa645b34 in _GLOBAL__sub_I_mixer.cpp /usr/src/dosbox-staging/build/clang-both-a_u/../../src/hardware/mixer.cpp
#6 0x7f173ff10eba in call_init csu/../csu/libc-start.c:145:3
#7 0x7f173ff10eba in __libc_start_main csu/../csu/libc-start.c:379:5
Indirect leak of 5224 byte(s) in 1 object(s) allocated from:
#0 0x55c7a8a80b3d in operator new(unsigned long) (/usr/src/dosbox-staging/build/clang-both-a_u/dosbox+0x1358b3d) (BuildId: 09f4c46c22a1b04de8e13e427d9d203a3193c043)
#1 0x55c7aa68e1ca in Chorus::Chorus(float, float, float, float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/Chorus.h:76:7
#2 0x55c7aa68df67 in ChorusEngine::setUpChorus(float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/ChorusEngine.h:82:23
#3 0x55c7aa647b40 in ChorusEngine::ChorusEngine(float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/ChorusEngine.h:55:9
#4 0x55c7aa645879 in __cxx_global_var_init /usr/src/dosbox-staging/build/clang-both-a_u/../../src/hardware/mixer.cpp:149:31
#5 0x55c7aa645b34 in _GLOBAL__sub_I_mixer.cpp /usr/src/dosbox-staging/build/clang-both-a_u/../../src/hardware/mixer.cpp
#6 0x7f173ff10eba in call_init csu/../csu/libc-start.c:145:3
#7 0x7f173ff10eba in __libc_start_main csu/../csu/libc-start.c:379:5
Indirect leak of 5224 byte(s) in 1 object(s) allocated from:
#0 0x55c7a8a80b3d in operator new(unsigned long) (/usr/src/dosbox-staging/build/clang-both-a_u/dosbox+0x1358b3d) (BuildId: 09f4c46c22a1b04de8e13e427d9d203a3193c043)
#1 0x55c7aa68e1ca in Chorus::Chorus(float, float, float, float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/Chorus.h:76:7
#2 0x55c7aa68de47 in ChorusEngine::setUpChorus(float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/ChorusEngine.h:80:23
#3 0x55c7aa647b40 in ChorusEngine::ChorusEngine(float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/ChorusEngine.h:55:9
#4 0x55c7aa645879 in __cxx_global_var_init /usr/src/dosbox-staging/build/clang-both-a_u/../../src/hardware/mixer.cpp:149:31
#5 0x55c7aa645b34 in _GLOBAL__sub_I_mixer.cpp /usr/src/dosbox-staging/build/clang-both-a_u/../../src/hardware/mixer.cpp
#6 0x7f173ff10eba in call_init csu/../csu/libc-start.c:145:3
#7 0x7f173ff10eba in __libc_start_main csu/../csu/libc-start.c:379:5
Indirect leak of 5224 byte(s) in 1 object(s) allocated from:
#0 0x55c7a8a80b3d in operator new(unsigned long) (/usr/src/dosbox-staging/build/clang-both-a_u/dosbox+0x1358b3d) (BuildId: 09f4c46c22a1b04de8e13e427d9d203a3193c043)
#1 0x55c7aa68e1ca in Chorus::Chorus(float, float, float, float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/Chorus.h:76:7
#2 0x55c7aa68e000 in ChorusEngine::setUpChorus(float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/ChorusEngine.h:83:23
#3 0x55c7aa647b40 in ChorusEngine::ChorusEngine(float) /usr/src/dosbox-staging/build/clang-both-a_u/../../include/../src/libs/tal-chorus/ChorusEngine.h:55:9
#4 0x55c7aa645879 in __cxx_global_var_init /usr/src/dosbox-staging/build/clang-both-a_u/../../src/hardware/mixer.cpp:149:31
#5 0x55c7aa645b34 in _GLOBAL__sub_I_mixer.cpp /usr/src/dosbox-staging/build/clang-both-a_u/../../src/hardware/mixer.cpp
#6 0x7f173ff10eba in call_init csu/../csu/libc-start.c:145:3
#7 0x7f173ff10eba in __libc_start_main csu/../csu/libc-start.c:379:5
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/tal-chorus/ChorusEngine.h | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/libs/tal-chorus/ChorusEngine.h b/src/libs/tal-chorus/ChorusEngine.h index 0837317c0..bfa7f7dc6 100644 --- a/src/libs/tal-chorus/ChorusEngine.h +++ b/src/libs/tal-chorus/ChorusEngine.h @@ -24,6 +24,8 @@ #if !defined(__ChorusEngine_h) #define __ChorusEngine_h +#include <memory> + #include "Chorus.h" #include "Params.h" #include "DCBlock.h" @@ -32,10 +34,10 @@ class ChorusEngine { public: - Chorus *chorus1L = {}; - Chorus *chorus1R = {}; - Chorus *chorus2L = {}; - Chorus *chorus2R = {}; + std::unique_ptr<Chorus> chorus1L = {}; + std::unique_ptr<Chorus> chorus1R = {}; + std::unique_ptr<Chorus> chorus2L = {}; + std::unique_ptr<Chorus> chorus2R = {}; DCBlock dcBlock1L = {}; DCBlock dcBlock1R = {}; @@ -55,14 +57,6 @@ public: setUpChorus(sampleRate); } - ~ChorusEngine() - { - delete chorus1L; - delete chorus1R; - delete chorus2L; - delete chorus2R; - } - void setSampleRate(float sampleRate) { setUpChorus(sampleRate); @@ -77,10 +71,10 @@ public: void setUpChorus(float sampleRate) { - chorus1L= new Chorus(sampleRate, 1.0f, 0.5f, 7.0f); - chorus1R= new Chorus(sampleRate, 0.0f, 0.5f, 7.0f); - chorus2L= new Chorus(sampleRate, 0.0f, 0.83f, 7.0f); - chorus2R= new Chorus(sampleRate, 1.0f, 0.83f, 7.0f); + chorus1L= std::make_unique<Chorus>(sampleRate, 1.0f, 0.5f, 7.0f); + chorus1R= std::make_unique<Chorus>(sampleRate, 0.0f, 0.5f, 7.0f); + chorus2L= std::make_unique<Chorus>(sampleRate, 0.0f, 0.83f, 7.0f); + chorus2R= std::make_unique<Chorus>(sampleRate, 1.0f, 0.83f, 7.0f); } inline void process(float *sampleL, float *sampleR) |