From b6190b5193b1eedce03013f998ca5ec5395de26f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 4 Nov 2015 19:20:34 +0100 Subject: [PATCH] CID 22527 Resource leak --- src/kernel/connection.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/kernel/connection.c b/src/kernel/connection.c index eecbd6c59..e08cbe806 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -151,14 +151,13 @@ connection *get_borders(const region * r1, const region * r2) connection *new_border(border_type * type, region * from, region * to) { - connection *b = calloc(1, sizeof(struct connection)); + connection *b, **bp = get_borders_i(from, to); - if (from && to) { - connection **bp = get_borders_i(from, to); - while (*bp) - bp = &(*bp)->next; - *bp = b; + assert(from && to); + while (*bp) { + bp = &(*bp)->next; } + *bp = b = calloc(1, sizeof(connection)); b->type = type; b->from = from; b->to = to;