-
Notifications
You must be signed in to change notification settings - Fork 13
Fix Unicode string null termination in StringToBytes #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2416,10 +2416,11 @@ internal static string StringFromBytes(byte[] bytes, int len) | |
| /// <internalonly/> | ||
| internal static byte[] StringToBytes(string value) | ||
| { | ||
| int size = value.Length * 2 + 1; | ||
| int size = value.Length * 2 + 2; | ||
| byte[] byteBuffer = new byte[size]; | ||
| byteBuffer[size - 1] = 0; | ||
| Encoding.Unicode.GetBytes(value.ToCharArray(), 0, value.Length, byteBuffer, 0); | ||
| byteBuffer[size - 2] = 0; | ||
| byteBuffer[size - 1] = 0; | ||
|
Comment on lines
+2422
to
+2423
|
||
| return byteBuffer; | ||
|
Comment on lines
2417
to
2424
|
||
| } | ||
|
|
||
|
|
||