2003-02-27 Dietmar Maurer <dietmar@ximian.com>
authorDietmar Maurer <dietmar@mono-cvs.ximian.com>
Thu, 27 Feb 2003 11:41:40 +0000 (11:41 -0000)
committerDietmar Maurer <dietmar@mono-cvs.ximian.com>
Thu, 27 Feb 2003 11:41:40 +0000 (11:41 -0000)
* marshal.c (mono_string_to_byvalstr): clear the memory as
suggested by Jerome Laban <jlaban@wanadoo.fr>

svn path=/trunk/mono/; revision=12023

mono/metadata/ChangeLog
mono/metadata/marshal.c
mono/tests/Makefile.am
mono/tests/libtest.c

index 333afe70f92018d1b9ffd35bf21d7a778b7f09fb..48eb98b64be7879788791affdf545bf4f7c2cf86 100644 (file)
@@ -1,3 +1,8 @@
+2003-02-27  Dietmar Maurer  <dietmar@ximian.com>
+
+       * marshal.c (mono_string_to_byvalstr): clear the memory as
+       suggested by Jerome Laban <jlaban@wanadoo.fr>
+
 2003-02-26  Dick Porter  <dick@ximian.com>
 
        * process.c: Cope with padding in .rsrc blocks
index 1e0093a80cddbbea522b8c5824e37b57e6a46435..52f7291381a1d58f33098dc7c347c61ea452c68e 100644 (file)
@@ -167,10 +167,10 @@ mono_string_to_byvalstr (gpointer dst, MonoString *src, int size)
        g_assert (dst != NULL);
        g_assert (size > 0);
 
-       if (!src) {
-               memset (dst, 0, size);
+       memset (dst, 0, size);
+       
+       if (!src)
                return;
-       }
 
        s = mono_string_to_utf8 (src);
        len = MIN (size, strlen (s));
index 93299dfd550ad6070ba688a0d6dbe66c78b2484c..4d151f5ff4ec1917e6c63bb830086387f574d510 100644 (file)
@@ -141,6 +141,7 @@ TEST_CS_SRC=                        \
        marshal2.cs             \
        marshal3.cs             \
        marshal4.cs             \
+       marshal5.cs             \
        thread.cs               \
        thread5.cs              \
        thread6.cs              \
index d38939e6cf1f29a880728e36723b257cd65557dd..b1b281bb4a9366d1f2775c128d0eb2a27342b256 100644 (file)
@@ -258,3 +258,34 @@ mono_test_empty_struct (int a, EmptyStruct es, int b)
        return 1;
 }
 #endif
+
+
+typedef struct {
+       char a[100];
+} ByValStrStruct;
+
+ByValStrStruct *
+mono_test_byvalstr_gen (void)
+{
+       ByValStrStruct *ret;
+       int i;
+       
+       ret = g_malloc(sizeof(ByValStrStruct));
+       memset(ret, 'a', sizeof(ByValStrStruct)-1);
+       ret->a[sizeof(ByValStrStruct)-1] = 0;
+
+       return ret;
+}
+
+int
+mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
+{
+       int ret;
+
+       ret = strcmp(data->a, correctString);
+       printf ("T1: %s\n", data->a);
+       printf ("T2: %s\n", correctString);
+
+       g_free(data);
+       return (ret != 0);
+}