Skip to content

Commit 465d540

Browse files
committed
crash: fix off-end read when copying environ array
1 parent 3974762 commit 465d540

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/crash/handler.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ bool CrashHandlerPrivate::minidumpCallback(
126126

127127
auto populateEnv = [&]() {
128128
auto senvi = 0;
129-
while (envi < 4095) {
130-
env[envi++] = environ[senvi++]; // NOLINT
129+
while (envi != 4095) {
130+
auto var = environ[senvi++]; // NOLINT
131+
if (var == nullptr) break;
132+
env[envi++] = var;
131133
}
132134

133135
env[envi] = nullptr;

0 commit comments

Comments
 (0)