From: UnknownShadow200 Date: Wed, 12 Jul 2017 07:15:33 +0000 (+1000) Subject: Fix X11 drag-n-drop returning wrong filename, and crashing X-Git-Tag: v3.0.0~84^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=65e59d9f425a5d6b482e73cfe119ec47f006d202;p=platform%2Fcore%2Fcsapi%2Fopentk.git Fix X11 drag-n-drop returning wrong filename, and crashing Wrong filename being returned was due to the filename being URL encoded. Crashing was due to the offset being past the end of the buffer returned from Marshal.AllocHGlobal. Fixes #570. --- diff --git a/src/OpenTK/Platform/X11/X11GLNative.cs b/src/OpenTK/Platform/X11/X11GLNative.cs index 34db010..2e90960 100644 --- a/src/OpenTK/Platform/X11/X11GLNative.cs +++ b/src/OpenTK/Platform/X11/X11GLNative.cs @@ -338,8 +338,8 @@ namespace OpenTK.Platform.X11 string[] fileNames = new string[splitted.Length]; for (int i = 0; i < splitted.Length; i++) { - // Delete start of name - file:// - fileNames[i] = splitted[i].Substring(7); + // Delete starting file://, filename data is URI-encoded + fileNames[i] = Uri.UnescapeDataString(splitted[i].Substring(7)); } return fileNames; @@ -866,9 +866,9 @@ namespace OpenTK.Platform.X11 else { formats = Marshal.AllocHGlobal(3 * IntPtr.Size); - Marshal.WriteIntPtr(formats, e.ClientMessageEvent.ptr3); - Marshal.WriteIntPtr(formats, IntPtr.Size * 2, e.ClientMessageEvent.ptr4); - Marshal.WriteIntPtr(formats, IntPtr.Size * 3, e.ClientMessageEvent.ptr5); + Marshal.WriteIntPtr(formats, IntPtr.Size * 0, e.ClientMessageEvent.ptr3); + Marshal.WriteIntPtr(formats, IntPtr.Size * 1, e.ClientMessageEvent.ptr4); + Marshal.WriteIntPtr(formats, IntPtr.Size * 2, e.ClientMessageEvent.ptr5); formatCount = 3; }