Mercurial > SDL_sound_CoreAudio
changeset 254:a73c51c12452
Memory access fixes.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 11 Feb 2002 07:04:06 +0000 |
parents | 6e1ee1f5be1b |
children | fedfb7975219 |
files | decoders/timidity/Makefile.testmidi decoders/timidity/resample.c decoders/timidity/timidity.c |
diffstat | 3 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/decoders/timidity/Makefile.testmidi Fri Feb 08 01:53:55 2002 +0000 +++ b/decoders/timidity/Makefile.testmidi Mon Feb 11 07:04:06 2002 +0000 @@ -2,7 +2,13 @@ CC = gcc +# Standard SDL_sound debugging CFLAGS = -g -I../.. -ansi -pedantic -Wall `sdl-config --cflags` -DDEBUG_CHATTER +LIBS = `sdl-config --libs` + +# Electric Fence debugging +# CFLAGS = -g -I../.. -ansi -pedantic -Wall `sdl-config --cflags` +# LIBS = `sdl-config --libs` -lefence OBJECTS = common.o instrum.o mix.o output.o playmidi.o readmidi.o resample.o \ tables.o timidity.o testmidi.o @@ -10,7 +16,7 @@ all: testmidi testmidi: $(OBJECTS) - $(CC) $(OBJECTS) $(CFLAGS) -o testmidi `sdl-config --libs` + $(CC) $(OBJECTS) $(CFLAGS) -o testmidi $(LIBS) clean: $(RM) testmidi *.o *~
--- a/decoders/timidity/resample.c Fri Feb 08 01:53:55 2002 +0000 +++ b/decoders/timidity/resample.c Mon Feb 11 07:04:06 2002 +0000 @@ -579,7 +579,12 @@ while (--count) { vptr = src + (ofs >> FRACTION_BITS); - v1 = *(vptr - 1); + /* + * Electric Fence to the rescue: Accessing *(vptr - 1) is not a + * good thing to do when vptr <= src. (TiMidity++ has a similar + * safe-guard here.) + */ + v1 = (vptr > src) ? *(vptr - 1) : 0; v2 = *vptr; v3 = *(vptr + 1); v4 = *(vptr + 2);
--- a/decoders/timidity/timidity.c Fri Feb 08 01:53:55 2002 +0000 +++ b/decoders/timidity/timidity.c Mon Feb 11 07:04:06 2002 +0000 @@ -446,11 +446,13 @@ if (master_tonebank[i]) { song->tonebank[i] = safe_malloc(sizeof(ToneBank)); + memset(song->tonebank[i], 0, sizeof(ToneBank)); song->tonebank[i]->tone = master_tonebank[i]->tone; } if (master_drumset[i]) { song->drumset[i] = safe_malloc(sizeof(ToneBank)); + memset(song->drumset[i], 0, sizeof(ToneBank)); song->drumset[i]->tone = master_drumset[i]->tone; } }