Commit d709e6d9 authored by Martin Finkel's avatar Martin Finkel

Call AllocHGlobal in the try/catch

parent 37c43bac
......@@ -127,9 +127,10 @@ namespace LibVLCSharp.Shared.Helpers
return IntPtr.Zero;
var bytes = Encoding.UTF8.GetBytes(str);
var nativeString = Marshal.AllocHGlobal(bytes.Length + 1);
var nativeString = IntPtr.Zero;
try
{
nativeString = Marshal.AllocHGlobal(bytes.Length + 1);
Marshal.Copy(bytes, 0, nativeString, bytes.Length);
Marshal.WriteByte(nativeString, bytes.Length, 0);
}
......
......@@ -154,9 +154,10 @@ namespace LibVLCSharp.Shared.Helpers
static void UseStructurePointer<T>(T structure, Action<IntPtr> action)
{
var structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(structure));
var structurePointer = IntPtr.Zero;
try
{
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(structure));
Marshal.StructureToPtr(structure, structurePointer, false);
action(structurePointer);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment