summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-03-24 11:48:25 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2017-03-24 11:55:06 +0100
commit2ee56ae4d3c90b77d77e9be8e5e00832256e50de (patch)
tree7b6464b8cd76877b316ed99fbd166c7d4cb288ba /src/ipcpd
parentd51b66d838f7d3235f869e3dc1b8e8f9fe8e1147 (diff)
downloadouroboros-2ee56ae4d3c90b77d77e9be8e5e00832256e50de.tar.gz
ouroboros-2ee56ae4d3c90b77d77e9be8e5e00832256e50de.zip
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.
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/normal/routing.c24
1 files 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 <ouroboros/logs.h>
#include <ouroboros/rib.h>
#include <ouroboros/rqueue.h>
+#include <ouroboros/utils.h>
#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);
}