We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3900

Summary: [PATCH] timidity/readmidi.c (getvl): check if the read is successful.
Product: SDL_mixer Reporter: Ozkan Sezer <sezeroz>
Component: miscAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: unspecified   
Hardware: All   
OS: All   

Description Ozkan Sezer 2017-10-21 10:23:44 UTC
readmidi.c (getvl): check if the read is successful.
fixes valgrind warning with broken midi files

diff --git a/timidity/readmidi.c b/timidity/readmidi.c
--- a/timidity/readmidi.c
+++ b/timidity/readmidi.c
@@ -45,7 +45,7 @@ static Sint32 getvl(SDL_RWops *rw)
   Uint8 c;
   for (;;)
     {
-      SDL_RWread(rw, &c, 1, 1);
+      if (!SDL_RWread(rw, &c, 1, 1)) return l;
       l += (c & 0x7f);
       if (!(c & 0x80)) return l;
       l<<=7;
Comment 1 Sam Lantinga 2017-10-21 11:04:05 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL_mixer/rev/6e38c1680f19