From: Ben Pfaff Date: Wed, 4 Sep 2013 19:33:06 +0000 (-0700) Subject: flow: Fix hypothetical memory leak in miniflow_move(). X-Git-Tag: sliver-openvswitch-2.0.90-1~16^2~32 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=cc1a2dcbba4dac352a294aef06b0131e6382d5b5;p=sliver-openvswitch.git flow: Fix hypothetical memory leak in miniflow_move(). Ordinarily a miniflow will use its inline_values if its values can fit, but there is nothing to prevent a small number of values from being stored in malloc()'d memory. If this happened, then miniflow_move() would leak memory. This commit fixes the problem. This is a hypothetical problem. I haven't seen it in practice. Signed-off-by: Ben Pfaff Acked-by: Ethan Jackson --- diff --git a/lib/flow.c b/lib/flow.c index 0e7c493a0..9ab19617a 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -1141,10 +1141,10 @@ miniflow_clone(struct miniflow *dst, const struct miniflow *src) void miniflow_move(struct miniflow *dst, struct miniflow *src) { - int n = miniflow_n_values(src); - if (n <= MINI_N_INLINE) { + if (src->values == src->inline_values) { dst->values = dst->inline_values; - memcpy(dst->values, src->values, n * sizeof *dst->values); + memcpy(dst->values, src->values, + miniflow_n_values(src) * sizeof *dst->values); } else { dst->values = src->values; }