This is an automated email from Gerrit.

Marc Schink ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/4053

-- gerrit

commit c15695a7eb5bfc706cd94ed1b22b475462925b9e
Author: Marc Schink <[email protected]>
Date:   Sat Jan 7 17:43:49 2017 +0100

    server/server: Remove all connections on shutdown
    
    This patch fixes a memory leak in the internal server. Steps for
    reproduction:
    
     * valgrind --leak-check=full --show-reachable=yes ./build/src/openocd
     * Establish more than one connection to OpenOCD (e.g. telnet)
     * Shutdown OpenOCD
     * Check for memory leaks in add_connection()
    
    Change-Id: I0ae6fcf2918fd9bdec350446d3e26742d08ff698
    Signed-off-by: Marc Schink <[email protected]>

diff --git a/src/server/server.c b/src/server/server.c
index 42f7561..51985a7 100644
--- a/src/server/server.c
+++ b/src/server/server.c
@@ -351,6 +351,21 @@ int add_service(char *name,
        return ERROR_OK;
 }
 
+static void remove_connections(struct service *service)
+{
+       struct connection *connection;
+
+       connection = service->connections;
+
+       while (connection) {
+               struct connection *tmp;
+
+               tmp = connection->next;
+               remove_connection(service, connection);
+               connection = tmp;
+       }
+}
+
 static int remove_services(void)
 {
        struct service *c = services;
@@ -359,6 +374,8 @@ static int remove_services(void)
        while (c) {
                struct service *next = c->next;
 
+               remove_connections(c);
+
                if (c->name)
                        free(c->name);
 

-- 

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to