Skip to content

Commit 5201bba

Browse files
author
Etsuro Fujita
committed
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 5891c7a, 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
1 parent 6e91b9c commit 5201bba

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/utils/activity/pgstat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ pgstat_build_snapshot(void)
11871187
Assert(!found);
11881188

11891189
entry->data = MemoryContextAlloc(pgStatLocal.snapshot.context,
1190-
kind_info->shared_size);
1190+
pgstat_get_entry_len(kind));
11911191

11921192
/*
11931193
* Acquire the LWLock directly instead of using
@@ -1196,7 +1196,7 @@ pgstat_build_snapshot(void)
11961196
LWLockAcquire(&stats_data->lock, LW_SHARED);
11971197
memcpy(entry->data,
11981198
pgstat_get_entry_data(kind, stats_data),
1199-
kind_info->shared_size);
1199+
pgstat_get_entry_len(kind));
12001200
LWLockRelease(&stats_data->lock);
12011201
}
12021202
dshash_seq_term(&hstat);

0 commit comments

Comments
 (0)