summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorEtsuro Fujita2025-05-03 11:00:00 +0000
committerEtsuro Fujita2025-05-03 11:00:00 +0000
commit5201bba266d7127397e08a2d954faa5a996c0139 (patch)
tree4ca062c154962c40cbf77098e947e91092d806b2 /src/backend
parent6e91b9c16ff53fadf75a545aabe5907f1c046d2f (diff)
Fix memory allocation/copy mistakes.
The previous code was allocating more memory and copying more data than necessary because it specified the wrong PgStat_KindInfo member as the size argument for MemoryContextAlloc and memcpy, respectively. Although these issues exist since 5891c7a8e, there have been no reports from the field. So for now, it seems sufficient to fix them in master. Author: Etsuro Fujita <[email protected]> Reviewed-by: Heikki Linnakangas <[email protected]> Reviewed-by: Gurjeet Singh <[email protected]> Discussion: https://postgr.es/m/CAPmGK15eTRCZTnfgQ4EuBNo%3DQLYGFEbXS_7m2dXqtkcT7L8qrQ%40mail.gmail.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/utils/activity/pgstat.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c
index a428b079c2e..8b57845e870 100644
--- a/src/backend/utils/activity/pgstat.c
+++ b/src/backend/utils/activity/pgstat.c
@@ -1187,7 +1187,7 @@ pgstat_build_snapshot(void)
Assert(!found);
entry->data = MemoryContextAlloc(pgStatLocal.snapshot.context,
- kind_info->shared_size);
+ pgstat_get_entry_len(kind));
/*
* Acquire the LWLock directly instead of using
@@ -1196,7 +1196,7 @@ pgstat_build_snapshot(void)
LWLockAcquire(&stats_data->lock, LW_SHARED);
memcpy(entry->data,
pgstat_get_entry_data(kind, stats_data),
- kind_info->shared_size);
+ pgstat_get_entry_len(kind));
LWLockRelease(&stats_data->lock);
}
dshash_seq_term(&hstat);