mirror of
https://github.com/percona/pg_stat_monitor.git
synced 2026-02-04 05:56:21 +00:00
PG-203: Fix memory leak.
The query_txt variable is allocated at the beginning of the pg_stat_monitor_internal() function and released at the end, but an extra malloc call to allocate it was added within an internal loop in the funcion, thus allocating memory for every loop iteration, without releasing the memory in the loop. The query_txt variable can be reused inside the loop body, so this commit removes the redundant declaration of query_txt from inside the loop, which also fixes the leak.
This commit is contained in:
@@ -1546,7 +1546,6 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||
uint64 planid = entry->key.planid;
|
||||
uint64 appid = entry->key.appid;
|
||||
unsigned char *buf = pgss_qbuf[bucketid];
|
||||
char *query_txt = (char*) malloc(PGSM_QUERY_MAX_LEN);
|
||||
#if PG_VERSION_NUM < 140000
|
||||
bool is_allowed_role = is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user