From 571bd01356e8c087a466b3e1a2532b0d59ef2ad7 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Wed, 6 Apr 2011 11:01:39 -0500 Subject: [PATCH] Fix crashes in Gdk.Pixbuf.Savev Patch from Bertrand Lorentz * gdk/Gdk.metadata: hide gdk_pixbuf_savev * gdk/Pixbuf.custom: manually implement Savev to NullTerm the string[] parameters. [Fixes #681111] --- gdk/Gdk.metadata | 2 +- gdk/Pixbuf.custom | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gdk/Gdk.metadata b/gdk/Gdk.metadata index 80ae9141a..de2c0e7d9 100644 --- a/gdk/Gdk.metadata +++ b/gdk/Gdk.metadata @@ -61,7 +61,7 @@ 1 1 1 - 1 + 1 1 1 1 diff --git a/gdk/Pixbuf.custom b/gdk/Pixbuf.custom index 46724d9e7..ebaf9105c 100644 --- a/gdk/Pixbuf.custom +++ b/gdk/Pixbuf.custom @@ -303,3 +303,23 @@ throw new GLib.GException (error); } + [DllImport("libgdk_pixbuf-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern unsafe bool gdk_pixbuf_savev(IntPtr raw, IntPtr filename, IntPtr type, IntPtr[] option_keys, IntPtr[] option_values, out IntPtr error); + + public unsafe bool Savev(string filename, string type, string[] option_keys, string[] option_values) { + IntPtr error = IntPtr.Zero; + IntPtr native_filename = GLib.Marshaller.StringToPtrGStrdup (filename); + IntPtr native_type = GLib.Marshaller.StringToPtrGStrdup (type); + IntPtr[] native_option_keys = NullTerm (option_keys); + IntPtr[] native_option_values = NullTerm (option_values); + bool saved = gdk_pixbuf_savev(Handle, native_filename, native_type, native_option_keys, native_option_values, out error); + GLib.Marshaller.Free (native_filename); + GLib.Marshaller.Free (native_type); + ReleaseArray (native_option_keys); + ReleaseArray (native_option_values); + + if (!saved) + throw new GLib.GException (error); + return saved; + } +