Skip to content

Mysqlnd mem fixes#21931

Open
devnexen wants to merge 3 commits intophp:PHP-8.4from
devnexen:mysqlnd_mem_fixes
Open

Mysqlnd mem fixes#21931
devnexen wants to merge 3 commits intophp:PHP-8.4from
devnexen:mysqlnd_mem_fixes

Conversation

@devnexen
Copy link
Copy Markdown
Member

@devnexen devnexen commented May 2, 2026

No description provided.

devnexen added 2 commits May 2, 2026 05:35
set_client_option_2d() built the temporary key string with the
connection's persistent flag but always released it with persistent=1.
On a duplicate-key update of the connect_attr hash, zend_hash_update()
does not retain the passed key, so the caller-owned non-persistent
string was freed via free() instead of efree(), tripping the
IS_STR_PERSISTENT assertion in debug builds and mismatching allocators
in release. Reachable by retrying mysqli_real_connect() on a handle
whose first connect failed, since mysqlnd re-adds _client_name and
_server_host on every connect attempt.
Comment thread ext/mysqlnd/mysqlnd_connection.c Outdated
GC_MAKE_PERSISTENT_LOCAL(Z_COUNTED(attrz));
} else {
str = zend_string_init(key, strlen(key), 0);
ZVAL_NEW_STR(&attrz, zend_string_init(value, strlen(value), 0));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could do the same with this line, and remove the else block.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants