From 650e15903c7baadc65a4a5a7773b6c1a5013fac4 Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Tue, 30 Sep 2008 14:19:47 -0700 Subject: [PATCH] Properly allocate flow action blocks in user-space switch. The user-space switch was allocating blocks to hold actions in flows that did not include the action header. --- switch/switch-flow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/switch/switch-flow.c b/switch/switch-flow.c index a42d00fb..133e4f89 100644 --- a/switch/switch-flow.c +++ b/switch/switch-flow.c @@ -173,11 +173,12 @@ struct sw_flow * flow_alloc(int n_actions) { struct sw_flow_actions *sfa; + size_t size = sizeof *sfa + (n_actions * sizeof sfa->actions[0]); struct sw_flow *flow = malloc(sizeof *flow); if (!flow) return NULL; - sfa = malloc(n_actions * sizeof sfa->actions[0]); + sfa = malloc(size); if (!sfa) { free(flow); return NULL; -- 2.30.2