Skip to content

Commit 037291e

Browse files
addaleaxMyles Borins
authored and
Myles Borins
committed
src: make sure Utf8Value always zero-terminates
Make sure dereferencing a `Utf8Value` instance always returns a zero-terminated string, even if the conversion to string failed. The corresponding bugfix in the master branch happened in 44a4032 (#6357). Ref: #6357 PR-URL: #7101 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Myles Borins <[email protected]>
1 parent a31153c commit 037291e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/util.cc

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ namespace node {
55

66
Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Local<v8::Value> value)
77
: length_(0), str_(str_st_) {
8+
// Make sure result is always zero-terminated, even if conversion to string
9+
// fails.
10+
str_st_[0] = '\0';
11+
812
if (value.IsEmpty())
913
return;
1014

0 commit comments

Comments
 (0)