Skip to content

Commit afd02b2

Browse files
committed
src: relax assertion in operator[] of MaybeStackBuffer
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.
1 parent 15a7f4c commit afd02b2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/node_env_var.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void RealEnvStore::Set(Isolate* isolate,
121121
node::Utf8Value val(isolate, value);
122122

123123
#ifdef _WIN32
124-
if (key.length() > 0 && key[0] == L'=') return;
124+
if (key[0] == L'=') return;
125125
#endif
126126
uv_os_setenv(*key, *val);
127127
DateTimeConfigurationChangeNotification(isolate, key);

src/util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,12 @@ class MaybeStackBuffer {
351351
}
352352

353353
T& operator[](size_t index) {
354-
CHECK_LT(index, length());
354+
CHECK_LT(index, length() + 1);
355355
return buf_[index];
356356
}
357357

358358
const T& operator[](size_t index) const {
359-
CHECK_LT(index, length());
359+
CHECK_LT(index, length() + 1);
360360
return buf_[index];
361361
}
362362

0 commit comments

Comments
 (0)