diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index 39fb75c33dd..52fbc95bbd4 100644 --- a/TSRM/tsrm_win32.c +++ b/TSRM/tsrm_win32.c @@ -710,6 +710,7 @@ TSRM_API int shmget(key_t key, size_t size, int flags) CloseHandle(shm->segment); } UnmapViewOfFile(shm->descriptor); + shm->descriptor = NULL; return -1; } @@ -745,8 +746,8 @@ TSRM_API int shmdt(const void *shmaddr) shm->descriptor->shm_lpid = getpid(); shm->descriptor->shm_nattch--; - ret = 1; - if (!ret && shm->descriptor->shm_nattch <= 0) { + ret = 0; + if (shm->descriptor->shm_nattch <= 0) { ret = UnmapViewOfFile(shm->descriptor) ? 0 : -1; shm->descriptor = NULL; } diff --git a/ext/shmop/tests/gh14537.phpt b/ext/shmop/tests/gh14537.phpt new file mode 100644 index 00000000000..05af26a70ff --- /dev/null +++ b/ext/shmop/tests/gh14537.phpt @@ -0,0 +1,27 @@ +--TEST-- +GH-14537: shmop Windows 11 crashes the process +--EXTENSIONS-- +shmop +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +object(Shmop)#1 (0) { +} + +Warning: shmop_open(): Unable to attach or create shared memory segment "No error" in %s on line %d +bool(false)