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.pull/94/head
parent
641c91980c
commit
33b22e4ef2
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue