|Summary:||Marshalling structs with strings fails|
|Product:||[Mono] Runtime||Reporter:||Martin Green <martin.green>|
|Severity:||normal||CC:||masafa, mohitk, mono-bugs+mono, mono-bugs+runtime, vargaz|
|Tags:||Is this bug a regression?:||---|
|Last known good build:|
|Attachments:||Project with a few simple tests for this issue|
Description Martin Green 2014-06-18 06:46:22 UTC
Created attachment 7104 [details] Project with a few simple tests for this issue Description of Problem: Marshalling structs with strings fails when there is no null terminator on the string. Steps to reproduce the problem: 1. Create a struct that contains a string set to MarshalAs ByValTStr. 2. Create a buffer from a string with no terminator. 3. Use Marshal.PtrToStructure to get an object and inspect the string. Actual Results: Appears to read past the end of the buffer. String is often null but sometimes contains the correct chars but with extra appended to it. Expected Results: Should read the string correctly. How often does this happen? Always. Additional Information: See attached project. Only tested with Xamarin Studio 4.2.2 (Mono 3.3?) and .Net 4.5 on Windows 7, but this was found in our live system on Mono 2.10 Linux.
Comment 1 Zoltan Varga 2014-06-29 09:25:02 UTC
Fixed in mono master faa73b12907c703464ec52ccd11fc2f9a9dd8bd3.