nint8835-archive / iTunesRichPresence

Bring iTunes now playing information to Discord using Rich Presence
https://itunesrichpresence.com
MIT License
274 stars 44 forks source link

Songs with long artist names crashes the program. #7

Closed seizuresmiley closed 6 years ago

seizuresmiley commented 6 years ago

This seems like a rare case, but I tried playing a song with very long artist text, the the program crashes. here's the crash log:

** Exception Text **

System.ArgumentException: Destination array was not long enough. Check destIndex and length, and the array's lower bounds. at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable) at iTunesRichPresence.DiscordRPC.RichPresence.StrClampBytes(String toclamp, Int32 maxbytes) at iTunesRichPresence.DiscordRPC.RichPresence.StrToPtr(String input, Int32 maxbytes) at iTunesRichPresence.DiscordRPC.RichPresence.GetStruct() at iTunesRichPresence.DiscordRPC.UpdatePresence(RichPresence presence) at iTunesRichPresence.MainForm.UpdatePresence() at iTunesRichPresence.MainForm.pollTimer_Tick(Object sender, EventArgs e) at System.Windows.Forms.Timer.OnTick(EventArgs e) at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

nint8835 commented 6 years ago

Huh, the crash is actually coming from within Discord's RPC code. Any chance I could have the artist text that caused the crash? I might have to truncate the information before it gets sent off to Discord

seizuresmiley commented 6 years ago

It's " Rie Kugimiya (釘宮 理恵), Chiaki Takahashi (たかはし 智秋), Asami Shimoda (下田 麻美) & Naomi Wakabayashi (若林 直美) " without the quotes.

nint8835 commented 6 years ago

Sure enough, that text is over the 128 byte limit, as expected. I should be able to implement some truncation to prevent the crash from happening

nint8835 commented 6 years ago

@seizuresmiley Alright, I believe I have a fix for this implemented. Can you DM me the file causing the issue over Discord? I'm nint8835#0001