mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix NULL arithmetic during system program execution
For the first child process execution, `TWG(process)` is `NULL`; we need to catch that to avoid undefined behavior. Closes GH-17470.
This commit is contained in:
parent
e4473abefc
commit
022a5fca91
2 changed files with 10 additions and 6 deletions
2
NEWS
2
NEWS
|
@ -9,6 +9,8 @@ PHP NEWS
|
||||||
(nielsdos)
|
(nielsdos)
|
||||||
. Fixed bug GH-17214 (Relax final+private warning for trait methods with
|
. Fixed bug GH-17214 (Relax final+private warning for trait methods with
|
||||||
inherited final). (ilutov)
|
inherited final). (ilutov)
|
||||||
|
. Fixed NULL arithmetic during system program execution on Windows. (cmb,
|
||||||
|
nielsdos)
|
||||||
|
|
||||||
- Enchant:
|
- Enchant:
|
||||||
. Fix crashes in enchant when passing null bytes. (nielsdos)
|
. Fix crashes in enchant when passing null bytes. (nielsdos)
|
||||||
|
|
|
@ -374,6 +374,7 @@ static process_pair *process_get(FILE *stream)
|
||||||
process_pair *ptr;
|
process_pair *ptr;
|
||||||
process_pair *newptr;
|
process_pair *newptr;
|
||||||
|
|
||||||
|
if (TWG(process) != NULL) {
|
||||||
for (ptr = TWG(process); ptr < (TWG(process) + TWG(process_size)); ptr++) {
|
for (ptr = TWG(process); ptr < (TWG(process) + TWG(process_size)); ptr++) {
|
||||||
if (ptr->stream == stream) {
|
if (ptr->stream == stream) {
|
||||||
break;
|
break;
|
||||||
|
@ -383,6 +384,7 @@ static process_pair *process_get(FILE *stream)
|
||||||
if (ptr < (TWG(process) + TWG(process_size))) {
|
if (ptr < (TWG(process) + TWG(process_size))) {
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
newptr = (process_pair*)realloc((void*)TWG(process), (TWG(process_size)+1)*sizeof(process_pair));
|
newptr = (process_pair*)realloc((void*)TWG(process), (TWG(process_size)+1)*sizeof(process_pair));
|
||||||
if (newptr == NULL) {
|
if (newptr == NULL) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue