Browse Source

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 44a40325da
(https://github.com/nodejs/node/pull/6357).

Ref: https://github.com/nodejs/node/pull/6357
PR-URL: https://github.com/nodejs/node/pull/7101
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
v4.x
Anna Henningsen 9 years ago
committed by Myles Borins
parent
commit
037291e31f
  1. 4
      src/util.cc

4
src/util.cc

@ -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;

Loading…
Cancel
Save