Skip to content

Commit

Permalink
src: make sure Utf8Value always zero-terminates
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
addaleax authored and Myles Borins committed Jun 24, 2016
1 parent a31153c commit 037291e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ namespace node {

Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Local<v8::Value> value)
: length_(0), str_(str_st_) {
// Make sure result is always zero-terminated, even if conversion to string
// fails.
str_st_[0] = '\0';

if (value.IsEmpty())
return;

Expand Down

0 comments on commit 037291e

Please sign in to comment.