On 2013-10-7 15:47, Willy Tarreau wrote:
Hi Godbach,

On Mon, Oct 07, 2013 at 03:37:19PM +0800, Godbach wrote:
Yes, I have checked the manual of free(), it said that "If ptr is NULL,
no operation is performed."
In fact it's true on *most* platforms, and all those supported by haproxy.
So we removed all of these "if" a few years ago to make the code more
readable and more maintainable. I remember that we even discovered some
copy-paste mistakes such as :

    if (a)
       free(a);
    if (b)
       free(b);
    if (b)
       free(c);

Please remove it directly.
Done :-)

Willy


Hi Willy,

Thanks for your so detailed explanation. And the patch is updated according with our discussion
for your information.

--
Best Regards,
Godbach

>From 75a874183092ef4f7a59a67b66d68edadf4727e3 Mon Sep 17 00:00:00 2001
From: Godbach <[email protected]>
Date: Mon, 7 Oct 2013 15:55:16 +0800
Subject: [PATCH] BUG/MINOR: deinit: free server map which is allocated in
 init_server_map()

Both static-rr and hash with type map-based call init_server_map() to allocate
server map, so the server map should be freed while doing cleanup.

Signed-off-by: Godbach <[email protected]>
---
 src/haproxy.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/haproxy.c b/src/haproxy.c
index ec9f513..bc03a73 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -975,6 +975,7 @@ void deinit(void)
                free(p->conf.lfs_file);
                free(p->conf.uniqueid_format_string);
                free(p->conf.uif_file);
+               free(p->lbprm.map.srv);
 
                for (i = 0; i < HTTP_ERR_SIZE; i++)
                        chunk_destroy(&p->errmsg[i]);
-- 
1.7.7

Reply via email to