# HG changeset patch # User thib # Date 1217930764 0 # Node ID fa8511a21d05f9eef7435676ed55961e612addff # Parent 2c890434e30f7b49e444293346981103c5cdad11 Fixes somes memory leaks diff --git a/font/font_face.cc b/font/font_face.cc --- a/font/font_face.cc +++ b/font/font_face.cc @@ -71,6 +71,7 @@ Face::Face(const char *name_orig, int in #endif } } + delete[] name; return; } diff --git a/music2/koedec_ogg.cc b/music2/koedec_ogg.cc --- a/music2/koedec_ogg.cc +++ b/music2/koedec_ogg.cc @@ -101,8 +101,12 @@ static int ogg_closefunc(void* datasourc int ogg_get_rate(FILE *stream) { OggVorbis_File vf; - ov_open(stream, &vf, NULL, 0); - return vf.vi->rate; + ov_callbacks callback(OV_CALLBACKS_DEFAULT); + callback.close_func = NULL; + ov_test_callbacks(stream, &vf, NULL, 0, callback); + int rate = vf.vi->rate; + ov_clear(&vf); + return rate; } extern char* decode_koe_ogg(AvgKoeInfo info, int* dest_len) { diff --git a/music2/music.cc b/music2/music.cc --- a/music2/music.cc +++ b/music2/music.cc @@ -220,6 +220,7 @@ void WavChunk::callback(void *userdata, memcpy(stream_dup, stream, len); memset(stream, 0, len); SDL_MixAudio(stream, (Uint8*)stream_dup, len, cur_vol); + delete[] stream_dup; return; } @@ -290,7 +291,7 @@ void MuSys::PlayKoe(const char* path) { } if (playing_koedata) { - delete[] playing_koedata; + free(playing_koedata); playing_koedata = 0; } diff --git a/music2/wavfile.cc b/music2/wavfile.cc --- a/music2/wavfile.cc +++ b/music2/wavfile.cc @@ -352,7 +352,7 @@ WAVFILE_Converter::WAVFILE_Converter(WAV static int conv_wave_rate(short* in_buf, int length, int in_rate, int out_rate, char* tmpbuf); WAVFILE_Converter::~WAVFILE_Converter() { if (cvt) { - if (cvt->buf) delete cvt->buf; + if (cvt->buf) delete[] cvt->buf; delete cvt; cvt = 0; } diff --git a/system/file.cc b/system/file.cc --- a/system/file.cc +++ b/system/file.cc @@ -526,6 +526,7 @@ void SCN2kFILE::ListupFiles(int fname_le arc_atom.push_back(atom); sprintf(sbuf, "seen%04d.txt",i); sbuf += 13; } + delete[] buf; fclose(stream); return; } @@ -1533,6 +1534,7 @@ bool G00CONV::Read_Type2(char* image) { } } delete[] uncompress_data; + delete[] region_table; return true; }