nint8835-archive / iTunesRichPresence

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

When playing a song of a long artist, a crash message will be displayed. #10

Closed book000 closed 6 years ago

book000 commented 6 years ago

A System.ArgumentException occurs when playing a song with a long artist name.

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)

The corresponding song is below.

ApplicationVersion: v1.2.2 (Latest release)

I like this application very much and using it. Thank you for your consideration.

book000 commented 6 years ago

My prediction is because the length of newstrbytes in DiscordRPC.cs line 187 is 0? var newstrbytes = new byte[] { }; -> var newstrbytes = new byte[maxbytes];

nint8835 commented 6 years ago

Just realized that I was shortening the artist and album name to the length limit, but then appending "..." to the end. The size limit should now be fixed so this crash does not happen in future releases.

book000 commented 6 years ago

Uh… I downloaded and executed v1.3.0, but System.ArgumentException occurred in the same way...

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)