[Mono-bugs] [Bug 58325][Maj] Changed - incorrect free in marshal code: mono/tests/pinvoke17

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 15 Oct 2004 17:36:26 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by grompf@sublimeintervention.com.

http://bugzilla.ximian.com/show_bug.cgi?id=58325

--- shadow/58325	2004-10-15 06:37:57.000000000 -0400
+++ shadow/58325.tmp.24465	2004-10-15 17:36:26.000000000 -0400
@@ -326,6 +326,34 @@
 
 -kangaroo
 
 
 ------- Additional Comments From lupus@ximian.com  2004-10-15 06:37 -------
 The issue with the incorrect free is present on x86, too.
+
+------- Additional Comments From grompf@sublimeintervention.com  2004-10-15 17:36 -------
+Index: metadata/marshal.c
+=======================================================
+============
+RCS file: /cvs/public/mono/mono/metadata/marshal.c,v
+retrieving revision 1.208
+diff -u -r1.208 marshal.c
+--- metadata/marshal.c  30 Sep 2004 10:28:34 -0000      1.208
++++ metadata/marshal.c  15 Oct 2004 19:46:31 -0000
+@@ -4126,8 +4126,10 @@
+                                emit_struct_free (mb, klass, m->orig_conv_args [argnum]);
+                        }
+ 
+-                       mono_mb_emit_ldloc (mb, conv_arg);
+-                       mono_mb_emit_icall (mb, g_free);
++                       if (!(t->attrs & PARAM_ATTRIBUTE_IN)) {
++                           mono_mb_emit_ldloc (mb, conv_arg);
++                           mono_mb_emit_icall (mb, g_free);
++                       }
+ 
+                        mono_mb_patch_addr (mb, pos2, mb->pos - (pos2 + 4));
+                }
+
+small patch to marshal.c to avoid freeing conv_arg on IN/OUTs (saves this double free)
+
+-kangaroo
+