aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2017-10-31 03:49:41 +0300
committerWohlstand <admin@wohlnet.ru>2017-10-31 03:49:41 +0300
commit3707313e7dea178a44f13daa653e072f9b930b66 (patch)
tree3a122b25041c9b3d7a0be1b818525ca97f5a8eae
parent634fefa614f29056e5b4dadc1e4db9ce61d49e59 (diff)
downloadlibADLMIDI-3707313e7dea178a44f13daa653e072f9b930b66.tar.gz
libADLMIDI-3707313e7dea178a44f13daa653e072f9b930b66.tar.bz2
libADLMIDI-3707313e7dea178a44f13daa653e072f9b930b66.zip
Small optimize of the IMF validator
-rw-r--r--src/adlmidi_load.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/adlmidi_load.cpp b/src/adlmidi_load.cpp
index 08892a5..3f2ad8c 100644
--- a/src/adlmidi_load.cpp
+++ b/src/adlmidi_load.cpp
@@ -578,6 +578,7 @@ riffskip:
{
// Try parsing as an IMF file
{
+ uint8_t raw[4];
size_t end = static_cast<uint8_t>(HeaderBuf[0]) + 256 * static_cast<uint8_t>(HeaderBuf[1]);
if(!end || (end & 3))
@@ -589,11 +590,13 @@ riffskip:
for(unsigned n = 0; n < 42; ++n)
{
- int64_t value1 = fr.getc();
- value1 += fr.getc() << 8;
+ if(fr.read(raw, 1, 4) != 4)
+ break;
+ int64_t value1 = raw[0];
+ value1 += raw[1] << 8;
sum1 += value1;
- int64_t value2 = fr.getc();
- value2 += fr.getc() << 8;
+ int64_t value2 = raw[2];
+ value2 += raw[3] << 8;
sum2 += value2;
}