From a0ceae5dd62de5b14134647906969d6c56df4a86 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 16 Jul 2020 06:40:27 +0200 Subject: [PATCH] BUG/MEDIUM: server: fix possibly uninitialized state file on close Previous fix dc6e8a9a7 ("BUG/MEDIUM: server: resolve state file handle leak on reload") traded a bug for another one, now we get this warning when building server.c, which is valid since f is not necessarily initialized (e.g. if no global state file is passed): src/server.c: In function 'apply_server_state': src/server.c:3272:3: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized] fclose(f); ^~~~~~~~~ Let's initialize it first. This whole code block should really be splitted, cleaned up and reorganized as it's possible that other similar bugs are hidden in it. This must be backported to the same branches the commit above is backported to (likely 2.2 and 2.1). (cherry picked from commit 2d067f93fbbecc2b25bb0374a1cd2552299f19f0) Signed-off-by: Willy Tarreau (cherry picked from commit 4881a40915f618a8b7455f5229f46724e6f9a70b) Signed-off-by: Christopher Faulet --- src/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server.c b/src/server.c index dd7b9bf..88f972a 100644 --- a/src/server.c +++ b/src/server.c @@ -3409,7 +3409,7 @@ void apply_server_state(void) struct state_line *st; struct ebmb_node *node, *next_node; - + f = NULL; global_file_version = 0; globalfilepathlen = 0; /* create the globalfilepath variable */ -- 1.7.10.4