Hi everyone,
 
    I ran into a problem while using the ByValStr attribute on a marshaled structure.
 
The problem was simple : I was doing the marshaling by hand using Marshal.StructureToPtr and Marshal.PtrToStructure and the memory pointed by the IntPtr was not always "clean". The method mono_to_byvalstr was assuming that the destination memory was set to zero, and when it was not, there was garbage after the correct string data.
 
    The fix is simple, just moved the memset a few lines before. Also, the microsoft runtime is setting the destination memory to zero, thus removing any garbage.
 
The fix is included in this post along with a test for the fix.
 
Could someone test it and commit it ?
 
Thanks,
Jerome.

Attachment: marshal5.cs
Description: Binary data

Attachment: byvalstr.diff
Description: Binary data

Reply via email to