Skip to content

Commit 3abf353

Browse files
author
Aleksandr Parfenov
committed
Fix potential memory corruption
1 parent 1ab3270 commit 3abf353

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Diff for: collector.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,13 @@ register_wait_collector(void)
3838
BackgroundWorker worker;
3939

4040
/* Set up background worker parameters */
41+
memset(&worker, 0, sizeof(worker));
4142
worker.bgw_flags = BGWORKER_SHMEM_ACCESS;
4243
worker.bgw_start_time = BgWorkerStart_ConsistentState;
4344
worker.bgw_restart_time = 0;
4445
worker.bgw_notify_pid = 0;
45-
#if PG_VERSION_NUM >= 100000 || defined(WIN32)
46-
memcpy(worker.bgw_library_name, "pg_wait_sampling", BGW_MAXLEN);
47-
memcpy(worker.bgw_function_name, CppAsString(collector_main), BGW_MAXLEN);
48-
#else
49-
worker.bgw_main = collector_main;
50-
#endif
46+
snprintf(worker.bgw_library_name, BGW_MAXLEN, "pg_wait_sampling");
47+
snprintf(worker.bgw_function_name, BGW_MAXLEN, CppAsString(collector_main));
5148
snprintf(worker.bgw_name, BGW_MAXLEN, "pg_wait_sampling collector");
5249
worker.bgw_main_arg = (Datum) 0;
5350
RegisterBackgroundWorker(&worker);

0 commit comments

Comments
 (0)