Skip to content

Commit cd92076

Browse files
authored
Merge pull request #8 from asp437/master
Fix potential memory corruption
2 parents 1ab3270 + 3abf353 commit cd92076

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

collector.c

Lines changed: 3 additions & 6 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy