Skip to content

Commit

Permalink
Merge pull request #8 from asp437/master
Browse files Browse the repository at this point in the history
Fix potential memory corruption
  • Loading branch information
ildus authored Mar 15, 2018
2 parents 1ab3270 + 3abf353 commit cd92076
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions collector.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@ register_wait_collector(void)
BackgroundWorker worker;

/* Set up background worker parameters */
memset(&worker, 0, sizeof(worker));
worker.bgw_flags = BGWORKER_SHMEM_ACCESS;
worker.bgw_start_time = BgWorkerStart_ConsistentState;
worker.bgw_restart_time = 0;
worker.bgw_notify_pid = 0;
#if PG_VERSION_NUM >= 100000 || defined(WIN32)
memcpy(worker.bgw_library_name, "pg_wait_sampling", BGW_MAXLEN);
memcpy(worker.bgw_function_name, CppAsString(collector_main), BGW_MAXLEN);
#else
worker.bgw_main = collector_main;
#endif
snprintf(worker.bgw_library_name, BGW_MAXLEN, "pg_wait_sampling");
snprintf(worker.bgw_function_name, BGW_MAXLEN, CppAsString(collector_main));
snprintf(worker.bgw_name, BGW_MAXLEN, "pg_wait_sampling collector");
worker.bgw_main_arg = (Datum) 0;
RegisterBackgroundWorker(&worker);
Expand Down

0 comments on commit cd92076

Please sign in to comment.