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 - native_midi_win32.c pointer truncation in midiStreamOpen call
Summary: native_midi_win32.c pointer truncation in midiStreamOpen call
Status: RESOLVED FIXED
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: 1.2.8
Hardware: x86 Windows (All)
: P2 major
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-13 13:31 UTC by Steven Noonan
Modified: 2009-09-26 02:19 UTC (History)
1 user (show)

See Also:


Attachments
DWORD_PTR patch for native_midi_win32 (1.54 KB, patch)
2008-12-22 08:57 UTC, Ozkan Sezer
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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!