fix memory leaks
[fw/openocd] / src / server / server.c
index 96f06b3feff65095bde1d1697a1c85b8ca806b55..1499e73875b94612c0bac5ffc5520d5c2038a231 100644 (file)
@@ -85,6 +85,7 @@ static int add_connection(struct service *service, struct command_context *cmd_c
                if (retval != ERROR_OK) {
                        close_socket(c->fd);
                        LOG_ERROR("attempted '%s' connection rejected", service->name);
+                       command_done(c->cmd_ctx);
                        free(c);
                        return retval;
                }
@@ -104,6 +105,7 @@ static int add_connection(struct service *service, struct command_context *cmd_c
                retval = service->new_connection(c);
                if (retval != ERROR_OK) {
                        LOG_ERROR("attempted '%s' connection rejected", service->name);
+                       command_done(c->cmd_ctx);
                        free(c);
                        return retval;
                }
@@ -124,6 +126,7 @@ static int add_connection(struct service *service, struct command_context *cmd_c
                retval = service->new_connection(c);
                if (retval != ERROR_OK) {
                        LOG_ERROR("attempted '%s' connection rejected", service->name);
+                       command_done(c->cmd_ctx);
                        free(c);
                        return retval;
                }