CID 22527 Resource leak

This commit is contained in:
Enno Rehling 2015-11-04 19:20:34 +01:00
parent 4d1f2327fe
commit b6190b5193
1 changed files with 5 additions and 6 deletions

View File

@ -151,14 +151,13 @@ connection *get_borders(const region * r1, const region * r2)
connection *new_border(border_type * type, region * from, region * to) 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) { assert(from && to);
connection **bp = get_borders_i(from, to); while (*bp) {
while (*bp) bp = &(*bp)->next;
bp = &(*bp)->next;
*bp = b;
} }
*bp = b = calloc(1, sizeof(connection));
b->type = type; b->type = type;
b->from = from; b->from = from;
b->to = to; b->to = to;