Skip to content

Commit

Permalink
fixes missing const qualifier in mixer::set_fx which was causing rand…
Browse files Browse the repository at this point in the history
…om memory corruption on some systems and in some situations
  • Loading branch information
samtupy committed Jul 15, 2024
1 parent 871a255 commit b7090b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ BOOL sound::close() {
return false;
}

int sound::set_fx(std::string& fx, int idx) {
int sound::set_fx(const std::string& fx, int idx) {
if (!output_mixer)
output_mixer = new mixer(parent_mixer, TRUE);
if (!output_mixer)
Expand Down Expand Up @@ -1557,7 +1557,7 @@ BOOL mixer::remove_sound(sound& s, BOOL internal) {
return TRUE;
}

int mixer::set_fx(std::string& fx, int idx) {
int mixer::set_fx(const std::string& fx, int idx) {
if(fx.size()<1) {
if(idx>=0&&idx<effects.size()) {
for(DWORD i=idx+1; i<effects.size(); i++)
Expand Down
4 changes: 2 additions & 2 deletions src/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class sound : public sound_base {
BOOL push_string(const std::string& buffer, BOOL stream_end = FALSE, int pcm_rate = 0, int pcm_chans = 0);
BOOL postload(const std::string& filename = std::string(""));
BOOL close();
int set_fx(std::string& fx, int idx = -1);
int set_fx(const std::string& fx, int idx = -1);
void set_length(float len) {
if (len >= 0) length = len;
}
Expand Down Expand Up @@ -229,7 +229,7 @@ class mixer : public sound_base {
BOOL add_sound(sound& s, BOOL internal = FALSE);
BOOL remove_sound(sound& s, BOOL internal = FALSE);
bool set_impulse_response(const std::string& response, float dry, float wet);
int set_fx(std::string& fx, int idx = -1);
int set_fx(const std::string& fx, int idx = -1);
BOOL set_mixer(mixer* m);
BOOL is_sliding();
BOOL is_pan_sliding();
Expand Down

0 comments on commit b7090b3

Please sign in to comment.