From fe822a9eeaf15ddd3f03ab08c9050d75ff827098 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 28 Mar 2019 12:29:10 +0900 Subject: [PATCH] Prevent potential file descriptor resource leak --- repmgr-action-node.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repmgr-action-node.c b/repmgr-action-node.c index bca0921e..45b27c1c 100644 --- a/repmgr-action-node.c +++ b/repmgr-action-node.c @@ -3108,11 +3108,12 @@ copy_file(const char *src_file, const char *dest_file) int a = 0; ptr_old = fopen(src_file, "r"); - ptr_new = fopen(dest_file, "w"); if (ptr_old == NULL) return false; + ptr_new = fopen(dest_file, "w"); + if (ptr_new == NULL) { fclose(ptr_old);