Skip to content

Commit

Permalink
Fix potential null pointer access during system program execution
Browse files Browse the repository at this point in the history
For the first child process execution, `TWG(process)` is `NULL`; we
need to catch that to avoid undefined behavior.
  • Loading branch information
cmb69 committed Jan 14, 2025
1 parent a6a290d commit 08fcb6d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions TSRM/tsrm_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,13 @@ static process_pair *process_get(FILE *stream)
process_pair *ptr;
process_pair *newptr;

for (ptr = TWG(process); ptr < (TWG(process) + TWG(process_size)); ptr++) {
for (ptr = TWG(process); ptr && ptr < (TWG(process) + TWG(process_size)); ptr++) {
if (ptr->stream == stream) {
break;
}
}

if (ptr < (TWG(process) + TWG(process_size))) {
if (ptr && ptr < (TWG(process) + TWG(process_size))) {
return ptr;
}

Expand Down

0 comments on commit 08fcb6d

Please sign in to comment.