1
0
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:
Christoph M. Becker
2022-11-02 11:35:30 +01:00
parent 2b5bed904e
commit d1c9ff5642
2 changed files with 4 additions and 3 deletions

View File

@@ -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;
}