mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix potential NULL pointer dereference Windows shm*() functions
`shm_get()` (not to be confused with `shmget()`) returns `NULL` if reallocation fails; we need to cater to that when calling the function. Closes GH-9872.
This commit is contained in:
@@ -702,7 +702,7 @@ TSRM_API void *shmat(int key, const void *shmaddr, int flags)
|
||||
{/*{{{*/
|
||||
shm_pair *shm = shm_get(key, NULL);
|
||||
|
||||
if (!shm->segment) {
|
||||
if (!shm || !shm->segment) {
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
@@ -726,7 +726,7 @@ TSRM_API int shmdt(const void *shmaddr)
|
||||
shm_pair *shm = shm_get(0, (void*)shmaddr);
|
||||
int ret;
|
||||
|
||||
if (!shm->segment) {
|
||||
if (!shm || !shm->segment) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -746,7 +746,7 @@ TSRM_API int shmctl(int key, int cmd, struct shmid_ds *buf)
|
||||
{/*{{{*/
|
||||
shm_pair *shm = shm_get(key, NULL);
|
||||
|
||||
if (!shm->segment) {
|
||||
if (!shm || !shm->segment) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user