Skip to content
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

fix(ext/ffi): Check CStr for UTF-8 validity on read #15318

Merged
merged 14 commits into from
Aug 5, 2022
Prev Previous commit
Next Next commit
Make error a bit more visible
  • Loading branch information
aapoalas committed Jul 27, 2022
commit 1421bd227c80637287cf8d8d35e4ede2e7be4f83
6 changes: 5 additions & 1 deletion test_ffi/tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,11 @@ assertEquals([...uint8Array], [
0x00
]);

assertThrows(() => charView.getCString(), TypeError, "Invalid CString pointer, not valid UTF-8");
try {
assertThrows(() => charView.getCString(), TypeError, "Invalid CString pointer, not valid UTF-8");
} catch (_err) {
console.log("Invalid UTF-8 characters to `v8::String`:", charView.getCString());
aapoalas marked this conversation as resolved.
Show resolved Hide resolved
}

(function cleanup() {
dylib.close();
Expand Down