jdksmidi
jdksmidi copied to clipboard
Infinite loop while reading MIDI file
Hi,
there is a possibility of infinite loop in fileread.cpp; EGetC may abort and set "abort_parse = true", but this boolean is not check by the caller and thus will result in an infinite loop. Fix here :
Index: libjdkmidi/src/jdksmidi_fileread.cpp
===================================================================
--- src/jdksmidi_fileread.cpp (revision 2257)
+++ src/jdksmidi_fileread.cpp (working copy)
@@ -468,10 +468,10 @@
}
lookfor = to_be_read - lng;
MsgInit();
- while ( to_be_read > lookfor )
+ while ( to_be_read > lookfor && !abort_parse )
MsgAdd ( EGetC() );
- if ( !event_handler->MetaEvent ( cur_time, type, act_msg_len, the_msg ) )
+ if ( !abort_parse && !event_handler->MetaEvent ( cur_time, type, act_msg_len, the_msg ) )
abort_parse = true;
break;