Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysqlnd: Make st_mysqlnd_stats.values a dynamic struct member #18246

Merged
merged 1 commit into from
Apr 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions ext/mysqlnd/mysqlnd_statistics.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, const MYSQLND_STRING
PHPAPI void
mysqlnd_stats_init(MYSQLND_STATS ** stats, const size_t statistic_count, const bool persistent)
{
*stats = pecalloc(1, sizeof(MYSQLND_STATS), persistent);
(*stats)->values = pecalloc(statistic_count, sizeof(uint64_t), persistent);
size_t size = zend_safe_address_guarded(statistic_count, sizeof(*(*stats)->values), sizeof(**stats));
*stats = pecalloc(1, size, persistent);
(*stats)->count = statistic_count;
#ifdef ZTS
(*stats)->LOCK_access = tsrm_mutex_alloc();
Expand All @@ -231,7 +231,6 @@ mysqlnd_stats_end(MYSQLND_STATS * stats, const bool persistent)
#ifdef ZTS
tsrm_mutex_free(stats->LOCK_access);
#endif
pefree(stats->values, persistent);
/* mnd_free will reference LOCK_access and crash...*/
pefree(stats, persistent);
}
Expand Down
2 changes: 1 addition & 1 deletion ext/mysqlnd/mysqlnd_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,11 @@ typedef struct st_mysqlnd_stats MYSQLND_STATS;

struct st_mysqlnd_stats
{
uint64_t *values;
size_t count;
#ifdef ZTS
MUTEX_T LOCK_access;
#endif
uint64_t values[] ZEND_ELEMENT_COUNT(count);
};


Expand Down
Loading