From 2ee56ae4d3c90b77d77e9be8e5e00832256e50de Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Fri, 24 Mar 2017 11:48:25 +0100 Subject: ipcpd: normal: Fix bad free This fixes a bad free. The table was only freed if it was NULL, instead of the other way around. --- src/ipcpd/normal/routing.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ipcpd/normal/routing.c b/src/ipcpd/normal/routing.c index 3a72bf36..f8705991 100644 --- a/src/ipcpd/normal/routing.c +++ b/src/ipcpd/normal/routing.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "routing.h" #include "ribmgr.h" @@ -65,25 +66,24 @@ struct { static void * calculate_pff(void * o) { struct routing_table ** table; - ssize_t i; - int j; + ssize_t n_table; (void) o; while (true) { - i = graph_routing_table(routing.graph, ipcpi.dt_addr, &table); - if (table != NULL) { - /* - * FIXME: Calculate address to fd here - * and fill in PFF - */ + n_table = graph_routing_table(routing.graph, + ipcpi.dt_addr, &table); + if (table == NULL) { + sleep(RECALC_TIME); + continue; } - for (j = 0; j < i; j++) { - free(table[j]); - } - free(table); + /* + * FIXME: Calculate address to fd here + * and fill in PFF + */ + freepp(struct routing_table, table, n_table); sleep(RECALC_TIME); } -- cgit v1.2.3