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 585

Summary: native_midi_win32.c pointer truncation in midiStreamOpen call
Product: SDL_mixer Reporter: Steven Noonan <steven>
Component: miscAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: sezeroz
Version: 1.2.8   
Hardware: x86   
OS: Windows (All)   
Attachments: DWORD_PTR patch for native_midi_win32

Description Steven Noonan 2008-05-13 13:31:36 UTC
I've just recently tested my application compiled for x86_64 (AMD64, x64, whatever you want to call it). Unfortunately there's one flaw in SDL_mixer which causes a pointer truncation and subsequent memory access violation and crash.
Comment 1 Steven Noonan 2008-05-13 13:33:52 UTC
I would normally attach the patch, but I'm getting Bugzilla internal errors when trying to upload it:

Internal Error

Bugzilla has suffered an internal error. Please save this page and send it to bugmaster@icculus.org with details of what you were doing at the time this message appeared.

URL: http://bugzilla.libsdl.org/attachment.cgi
undef error - Undefined subroutine Fh::slice at data/template/template/en/default/global/hidden-fields.html.tmpl line 58 



So, here's the patch text:
--- SDL_mixer-1.2.8-1/native_midi/native_midi_win32.c	2008-05-13 13:24:56.287800000 -0700
+++ SDL_mixer-1.2.8/native_midi/native_midi_win32.c	2008-05-13 13:25:53.615000000 -0700
@@ -181,7 +181,7 @@
   MMRESULT merr;
   HMIDISTRM MidiStream;
 
-  merr=midiStreamOpen(&MidiStream,&MidiDevice,1,(DWORD)&MidiProc,0,CALLBACK_FUNCTION);
+  merr=midiStreamOpen(&MidiStream,&MidiDevice,1,(DWORD_PTR)&MidiProc,0,CALLBACK_FUNCTION);
   if (merr!=MMSYSERR_NOERROR)
     MidiStream=0;
   midiStreamClose(MidiStream);

Comment 2 Ozkan Sezer 2008-12-22 08:57:42 UTC
Created attachment 284 [details]
DWORD_PTR patch for native_midi_win32

I think more changes are necessary to MidiProc for win64:
see, for example, a ptr is being cast to DWORD in the switch
statement.  Can any of you guys review the attached patch?

Ozkan
Comment 3 Sam Lantinga 2009-09-26 02:19:31 UTC
Looks good, your patch is in for the next release.

Thanks!