]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: server: fix possibly uninitialized state file on close
authorWilly Tarreau <w@1wt.eu>
Thu, 16 Jul 2020 04:40:27 +0000 (06:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 16 Jul 2020 04:44:04 +0000 (06:44 +0200)
commit2d067f93fbbecc2b25bb0374a1cd2552299f19f0
treeaff8888368647f8820fbae0d8bc0c1d193ed1abd
parentdc6e8a9a7b19052b8fd8ab7f9a84a4a95b4a6d5b
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).
src/server.c