MidiBuffer problems


#1

I use MidiBuffer to hold large amount of MidiEvents, but i’m getting crashes when doing addEvents() method (adding my large buffer to another). I have 4080 events in the MidiBuffer

my call is:

internalMidiBuffer.addEvents (messagesToAdd, 0, -1, 0);

the MidiBuffer method that causes a crash is MidiBuffer::addEvent and the line is:

        if (bytesToMove > 0)
            memmove (d + numBytes + 6,
                     d,
                     bytesToMove);

i added a watcher and it looks like this

-		newData	0x03dd7bc2 "°c•"	const unsigned char * const
			176 '°'	const unsigned char
		numBytes	3	const int
		bytesToMove	4294959259	const unsigned int
		bytesUsed	0	int
-		d	0x03dfee9d "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"	unsigned char *
			205 'Í'	unsigned char
		sampleNumber	1428	const int
		maxBytes	3	const int

the bytesToMove var looks very big to me, dunno why. Any ideas ?


#2

Hmm - looks like there’s a signed/unsigned overflow happening there - try tweaking this line:

const int bytesToMove = bytesUsed - (int) (d - getData());


#3

that helped, thank you. i just wanted to mention the MidiMessageCollector and Standalone plugin wrapper nor working with large sysex thinggy. perhaps you can have a look at that. but if you can’t that’s cool too :slight_smile: