mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-06-25 05:51:23 +00:00
Fixed memory corruption on string return type marshaling
This commit is contained in:
parent
4b3aac38b6
commit
e9f54dc61e
|
@ -206,7 +206,14 @@ namespace OpenTK.Platform.SDL2
|
||||||
|
|
||||||
[SuppressUnmanagedCodeSecurity]
|
[SuppressUnmanagedCodeSecurity]
|
||||||
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_JoystickName", ExactSpelling = true)]
|
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_JoystickName", ExactSpelling = true)]
|
||||||
public static extern string JoystickName(IntPtr joystick);
|
static extern IntPtr JoystickNameInternal(IntPtr joystick);
|
||||||
|
public static string JoystickName(IntPtr joystick)
|
||||||
|
{
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
return new string((sbyte*)JoystickNameInternal(joystick));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[SuppressUnmanagedCodeSecurity]
|
[SuppressUnmanagedCodeSecurity]
|
||||||
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_JoystickNumAxes", ExactSpelling = true)]
|
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_JoystickNumAxes", ExactSpelling = true)]
|
||||||
|
|
Loading…
Reference in a new issue