Skip to content

Commit

Permalink
src: relax assertion in operator[] of MaybeStackBuffer
Browse files Browse the repository at this point in the history
Setting environment variables on Windows was causing an abort because
the assertion did not account for the null-terminator at the end of the
buffer.
  • Loading branch information
bl-ue committed Apr 19, 2020
1 parent 15a7f4c commit afd02b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/node_env_var.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void RealEnvStore::Set(Isolate* isolate,
node::Utf8Value val(isolate, value);

#ifdef _WIN32
if (key.length() > 0 && key[0] == L'=') return;
if (key[0] == L'=') return;
#endif
uv_os_setenv(*key, *val);
DateTimeConfigurationChangeNotification(isolate, key);
Expand Down
4 changes: 2 additions & 2 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,12 @@ class MaybeStackBuffer {
}

T& operator[](size_t index) {
CHECK_LT(index, length());
CHECK_LT(index, length() + 1);
return buf_[index];
}

const T& operator[](size_t index) const {
CHECK_LT(index, length());
CHECK_LT(index, length() + 1);
return buf_[index];
}

Expand Down

0 comments on commit afd02b2

Please sign in to comment.