Skip to content

Commit e5471f9

Browse files
authored
Merge pull request #204 from chrbauer/issue/config_strings_with_trailing_zeros
Remove trailing zeros from Socket options strings
2 parents 35b57c4 + 2ce1832 commit e5471f9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ZSocket.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,9 @@ public bool GetOption(ZSocketOption option, out string value)
920920
{
921921
if (GetOption(option, optionValue, ref optionLength))
922922
{
923-
value = Marshal.PtrToStringAnsi(optionValue, optionLength);
923+
if (optionLength > 0 && Marshal.ReadByte(optionValue.Ptr, optionLength - 1) == 0)
924+
optionLength--; // remove traling '\0'
925+
value = Marshal.PtrToStringAnsi(optionValue, optionLength);
924926
return true;
925927
}
926928
return false;

0 commit comments

Comments
 (0)