git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6e91b9c)
Fix memory allocation/copy mistakes.
Sat, 3 May 2025 11:00:00 +0000 (20:00 +0900)
Sat, 3 May 2025 11:00:00 +0000 (20:00 +0900)
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 <etsuro.fujita@gmail.com>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: Gurjeet Singh <gurjeet@singh.im>
Discussion: https://postgr.es/m/CAPmGK15eTRCZTnfgQ4EuBNo%3DQLYGFEbXS_7m2dXqtkcT7L8qrQ%40mail.gmail.com


diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c
index a428b079c2e56223f6c3613aa8b27ed0628d2609..8b57845e8709f8b478b43017dc09a40dd5b5199e 100644 (file)
--- 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);
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /