[php-src] PR #20940: Incorrect SOCKETS_G(wsa_info) memory deallocation Win32
| From: | EdmondDantes | Date: | Wed, 14 Jan 2026 20:37:47 +0000 |
| Subject: | [php-src] PR #20940: Incorrect SOCKETS_G(wsa_info) memory deallocation Win32 | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-34560@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20940
Author: EdmondDantes
```c
PHP_FUNCTION(socket_wsaprotocol_info_export)
{
.....
// allocate Request memory here
seg_name = zend_strpprintf(0, "php_wsa_for_%u", SOCKETS_G(wsa_child_count)++);
map = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(WSAPROTOCOL_INFO),
ZSTR_VAL(seg_name));
if (NULL != map) {
// put to persistent memory array
zend_hash_add_ptr(&(SOCKETS_G(wsa_info)), seg_name, map);
```
Memory allocated for the request is destroyed before the
SOCKETS_G(wsa_info) array is
destructed
If the socket_wsaprotocol_info_release method is not called, the application terminates
with the message "zend_mm_heap corrupted"
The code proposed in this patch is not ideal, and it may be worth removing the creation of the array
in persistent memory. I do not fully understand the reason why it was done this way. Nevertheless,
this code works correctly.