# HG changeset patch # User Ryan C. Gordon # Date 1013411046 0 # Node ID a73c51c12452e8d5153a319068949ccaf3cfa73b # Parent 6e1ee1f5be1b7f5d67fe027225800a65c3475dc6 Memory access fixes. diff -r 6e1ee1f5be1b -r a73c51c12452 decoders/timidity/Makefile.testmidi --- 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 *~ diff -r 6e1ee1f5be1b -r a73c51c12452 decoders/timidity/resample.c --- 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); diff -r 6e1ee1f5be1b -r a73c51c12452 decoders/timidity/timidity.c --- 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; } }