Fix UnixEncoding.GetBytes() for empty strings (#18520)
commit1fd0748362e9014469fc7e6390826c7a5fdab027
authorSteffen Kieß <kiess@ki4.de>
Mon, 27 Jan 2020 16:00:16 +0000 (27 17:00 +0100)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 27 Jan 2020 16:00:16 +0000 (27 17:00 +0100)
tree9d67adab6dc23f6ccb6dac38e41a1eedca5d019d
parent66ff74a1f37a327da3148990b292c8e1c6ec6f69
Fix UnixEncoding.GetBytes() for empty strings (#18520)

Current versions of the mono return a null pointer as address of the first
element for empty arrays, i.e.

    fixed (byte* ptr = new byte[0]) Console.WriteLine (ptr == null);

will print "true". This causes a problem in the UnixEncoding class where it
triggers a check for null pointers. Fix this by allowing null pointers when
the number of elements is zero.
mcs/class/Mono.Posix/Mono.Unix/UnixEncoding.cs
mcs/class/Mono.Posix/Test/Mono.Unix/UnixEncodingTest.cs