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
(nodejs#6357).
  • Loading branch information
addaleax committed Jun 2, 2016
1 parent d869f1e commit 7f072d7
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 7f072d7

Please sign in to comment.