Skip to content

Commit 08fcb6d

Browse files
committed
Fix potential null pointer access during system program execution
For the first child process execution, `TWG(process)` is `NULL`; we need to catch that to avoid undefined behavior.
1 parent a6a290d commit 08fcb6d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

TSRM/tsrm_win32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,13 @@ static process_pair *process_get(FILE *stream)
374374
process_pair *ptr;
375375
process_pair *newptr;
376376

377-
for (ptr = TWG(process); ptr < (TWG(process) + TWG(process_size)); ptr++) {
377+
for (ptr = TWG(process); ptr && ptr < (TWG(process) + TWG(process_size)); ptr++) {
378378
if (ptr->stream == stream) {
379379
break;
380380
}
381381
}
382382

383-
if (ptr < (TWG(process) + TWG(process_size))) {
383+
if (ptr && ptr < (TWG(process) + TWG(process_size))) {
384384
return ptr;
385385
}
386386

0 commit comments

Comments
 (0)