diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-01-03 18:12:41 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-01-03 18:13:04 +0100 |
commit | 4c6ad099c649b81d03a6593009565ecbd447ea10 (patch) | |
tree | 3ae6aaaf3da39d2ff42f8704b5f32e1a532249a2 /TSRM | |
parent | 7f02b5fc472303cc395ebcbe8ac9ed89ff8b4425 (diff) | |
parent | 18172303f41b9891ae4b78b0c6f70d0d47ed539f (diff) | |
download | php-git-4c6ad099c649b81d03a6593009565ecbd447ea10.tar.gz |
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
Fix #78538: shmop memory leak
Diffstat (limited to 'TSRM')
-rw-r--r-- | TSRM/tsrm_win32.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index e16c946131..40331f122c 100644 --- a/TSRM/tsrm_win32.c +++ b/TSRM/tsrm_win32.c @@ -720,6 +720,7 @@ TSRM_API void *shmat(int key, const void *shmaddr, int flags) TSRM_API int shmdt(const void *shmaddr) {/*{{{*/ shm_pair *shm = shm_get(0, (void*)shmaddr); + int ret; if (!shm->segment) { return -1; @@ -729,7 +730,12 @@ TSRM_API int shmdt(const void *shmaddr) shm->descriptor->shm_lpid = getpid(); shm->descriptor->shm_nattch--; - return UnmapViewOfFile(shm->addr) ? 0 : -1; + ret = UnmapViewOfFile(shm->addr) ? 0 : -1; + if (!ret && shm->descriptor->shm_nattch <= 0) { + ret = UnmapViewOfFile(shm->descriptor) ? 0 : -1; + shm->descriptor = NULL; + } + return ret; }/*}}}*/ TSRM_API int shmctl(int key, int cmd, struct shmid_ds *buf) |