Skip to content

fix OOB on String.UTF8.encode using nullTerminated = true#2173

Merged
dcodeIO merged 3 commits intoAssemblyScript:mainfrom
romdotdog:nullterm-fix
Dec 13, 2021
Merged

fix OOB on String.UTF8.encode using nullTerminated = true#2173
dcodeIO merged 3 commits intoAssemblyScript:mainfrom
romdotdog:nullterm-fix

Conversation

@romdotdog
Copy link
Copy Markdown
Contributor

@romdotdog romdotdog commented Dec 11, 2021

fixes #2021

Examples

before it worked like this

String.UTF8.byteLength("a\0", true); // -> 2
String.UTF8.encode("a\0", true); // writes 0x61, 0x00, and then another 0x00

now it works like this

String.UTF8.byteLength("a\0", true); // -> 2
String.UTF8.encode("a\0", true); // writes 0x61, 0x00 and breaks because of the null
  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@romdotdog romdotdog requested a review from dcodeIO December 12, 2021 18:24
@dcodeIO dcodeIO merged commit 09beb42 into AssemblyScript:main Dec 13, 2021
@dcodeIO
Copy link
Copy Markdown
Member

dcodeIO commented Dec 13, 2021

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maybe there is a bug for String.UTF8.encode and String.UTF8.decode

2 participants