AUDIO: Small cleanup in MidiParser_XMIDI::loadMusic

This commit is contained in:
Max Horn 2011-06-09 18:16:14 +02:00
parent bdad493f3f
commit 55e1b08e22

View file

@ -256,26 +256,25 @@ bool MidiParser_XMIDI::loadMusic(byte *data, uint32 size) {
// Add eight bytes
i += 8;
if (memcmp(buf, "INFO", 4)) {
// Must align
pos += (chunk_len + 1) & ~1;
i += (chunk_len + 1) & ~1;
continue;
if (memcmp(buf, "INFO", 4) == 0) {
// Must be at least 2 bytes long
if (chunk_len < 2) {
warning("Invalid chunk length %d for 'INFO' block", (int)chunk_len);
return false;
}
_num_tracks = (byte)read2low(pos);
if (chunk_len > 2) {
warning("Chunk length %d is greater than 2", (int)chunk_len);
//pos += chunk_len - 2;
}
break;
}
// Must be at least 2 bytes long
if (chunk_len < 2) {
warning("Invalid chunk length %d for 'INFO' block", (int)chunk_len);
return false;
}
_num_tracks = (byte)read2low(pos);
if (chunk_len > 2) {
warning("Chunk length %d is greater than 2", (int)chunk_len);
pos += chunk_len - 2;
}
break;
// Must align
pos += (chunk_len + 1) & ~1;
i += (chunk_len + 1) & ~1;
}
// Didn't get to fill the header