[sre] Handle null values in MarshalAsAttribute CustomAttributeBuilder
commit972f29179dc11558902d89b55ae2f333c71a9aa9
authorAleksey Kliger <alklig@microsoft.com>
Thu, 7 Feb 2019 22:57:27 +0000 (7 17:57 -0500)
committerMarek Safar <marek.safar@gmail.com>
Fri, 8 Feb 2019 09:56:08 +0000 (8 10:56 +0100)
tree75b0e33660fb3c22e1059ce32d8783cdf8b0728c
parent49c0a9c2def3e1fb4daacaca4f1ff21fbf4dbc9b
[sre] Handle null values in MarshalAsAttribute CustomAttributeBuilder

Normally strings are encoded as length-then-utf8 in ECMA-335.  But a null
String is encoded as just the byte 0xFF.

When we make a CustomAttributeBuilder for a MarshalAsAttribute and attach it to
some parameter we first encode the CAB as a byte blob and then decode it in
CAB.get_umarshal into a UnmanagedMarshal attribute.  But the decoding didn't
account for the possibility of null strings.

Fixes https://github.com/mono/mono/issues/12747
mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs
mcs/class/corlib/Test/System.Reflection.Emit/CustomAttributeBuilderTest.cs