Skip to content

Commit 4c6ad09

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78538: shmop memory leak
2 parents 7f02b5f + 1817230 commit 4c6ad09

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ PHP NEWS
5959
- Session:
6060
. Fixed bug #79031 (Session unserialization problem). (Nikita)
6161

62+
- Shmop:
63+
. Fixed bug #78538 (shmop memory leak). (cmb)
64+
6265
- Sqlite3:
6366
. Fixed bug #79056 (sqlite does not respect PKG_CONFIG_PATH during
6467
compilation). (Nikita)

TSRM/tsrm_win32.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ TSRM_API void *shmat(int key, const void *shmaddr, int flags)
720720
TSRM_API int shmdt(const void *shmaddr)
721721
{/*{{{*/
722722
shm_pair *shm = shm_get(0, (void*)shmaddr);
723+
int ret;
723724

724725
if (!shm->segment) {
725726
return -1;
@@ -729,7 +730,12 @@ TSRM_API int shmdt(const void *shmaddr)
729730
shm->descriptor->shm_lpid = getpid();
730731
shm->descriptor->shm_nattch--;
731732

732-
return UnmapViewOfFile(shm->addr) ? 0 : -1;
733+
ret = UnmapViewOfFile(shm->addr) ? 0 : -1;
734+
if (!ret && shm->descriptor->shm_nattch <= 0) {
735+
ret = UnmapViewOfFile(shm->descriptor) ? 0 : -1;
736+
shm->descriptor = NULL;
737+
}
738+
return ret;
733739
}/*}}}*/
734740

735741
TSRM_API int shmctl(int key, int cmd, struct shmid_ds *buf)

0 commit comments

Comments
 (0)