ThioJoe / Edit-Clipboard-Contents

Allows viewing, editing, and even deleting individual items within the Windows clipboard
GNU General Public License v3.0
139 stars 2 forks source link

Program crashes when using Clipboard.SetData() #4

Closed tigrouind closed 3 weeks ago

tigrouind commented 3 weeks ago

Step to reproduce : In a Winforms application, run the following code :

Clipboard.SetData("Test", new MemoryStream());

Upon refresh, the program will crash and throw this exception :

System.ArgumentException :The destination array is not long enough to copy all the elements in the collection. 
Check the array index and length.
   à System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   à System.BitConverter.ToInt64(Byte[] value, Int32 startIndex)
   à EditClipboardContents.MainForm.SetDataInfo(String formatName, Byte[] rawData)
   à EditClipboardContents.MainForm.ProcessClipboardData()
   à EditClipboardContents.MainForm.RefreshClipboardItems()
   à EditClipboardContents.MainForm.RefreshClipboardAndRestoreSelection()
   à System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   à System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
   à System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   à System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   à System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   à System.Windows.Forms.Control.WndProc(Message& m)
   à System.Windows.Forms.ToolStrip.WndProc(Message& m)
   à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
ThioJoe commented 3 weeks ago

Hm ok yea i see the problem. It has to do with the DataObject format being blank and an unexpected length. I'll have to add something to handle that and also add something else to handle data processing errors in general

ThioJoe commented 3 weeks ago

Ok should be fixed with release version 1.5.2