From: William Tu Date: Tue, 5 Jan 2016 21:38:41 +0000 (-0800) Subject: ovs-ofctl: Fix memory leak reported by valgrind. X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=43d68d98ed6274fe4b7cc8cc66bca65fa5a0a37c ovs-ofctl: Fix memory leak reported by valgrind. Reported by 348: ovs-ofctl parse-flows (skb_priority) Reason: return without freeing memory Signed-off-by: William Tu Signed-off-by: Daniele Di Proietto Co-authored-by: Daniele Di Proietto Signed-off-by: Ben Pfaff --- diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c index c346f102b..aa0cad7c1 100644 --- a/lib/ofp-parse.c +++ b/lib/ofp-parse.c @@ -1039,6 +1039,7 @@ parse_ofp_flow_mod_file(const char *file_name, int command, error = parse_ofp_flow_mod_str(&(*fms)[*n_fms], ds_cstr(&s), command, &usable); if (error) { + char *err_msg; size_t i; for (i = 0; i < *n_fms; i++) { @@ -1053,7 +1054,9 @@ parse_ofp_flow_mod_file(const char *file_name, int command, fclose(stream); } - return xasprintf("%s:%d: %s", file_name, line_number, error); + err_msg = xasprintf("%s:%d: %s", file_name, line_number, error); + free(error); + return err_msg; } *usable_protocols &= usable; /* Each line can narrow the set. */ *n_fms += 1;