Permalink
Browse files

AUDIO: Free strings with delete[] instead of free()

Because scumm_strdup(), unlike strdup(), allocates strings with
new, not malloc(). (CID 1395228, 1395233, 1395235, 1395236)
  • Loading branch information...
eriktorbjorn committed Aug 27, 2018
1 parent bfded21 commit 54d7336d0886d0a9960baba71168c3471cdb84c6
Showing with 7 additions and 4 deletions.
  1. +7 −4 audio/softsynth/fluidsynth.cpp
@@ -87,27 +87,30 @@ MidiDriver_FluidSynth::MidiDriver_FluidSynth(Audio::Mixer *mixer)
_outputRate = 96000;
}

// The string duplication below is there only because older versions (1.1.6
// and earlier?) of FluidSynth expected the string parameters to be non-const.

void MidiDriver_FluidSynth::setInt(const char *name, int val) {
char *name2 = scumm_strdup(name);

fluid_settings_setint(_settings, name2, val);
free(name2);
delete[] name2;
}

void MidiDriver_FluidSynth::setNum(const char *name, double val) {
char *name2 = scumm_strdup(name);

fluid_settings_setnum(_settings, name2, val);
free(name2);
delete[] name2;
}

void MidiDriver_FluidSynth::setStr(const char *name, const char *val) {
char *name2 = scumm_strdup(name);
char *val2 = scumm_strdup(val);

fluid_settings_setstr(_settings, name2, val2);
free(name2);
free(val2);
delete[] name2;
delete[] val2;
}

int MidiDriver_FluidSynth::open() {

0 comments on commit 54d7336

Please sign in to comment.