diff mbox

[ovs-dev,2/4] ofp-print.c: fix memory leak at ofp_print_bundle_add()

Message ID 1450981722-101437-2-git-send-email-u9012063@gmail.com
State Accepted
Headers show

Commit Message

William Tu Dec. 24, 2015, 6:28 p.m. UTC
Call ds_put_and_free_cstr instead of ds_put_cstr to free msg.
Reported by test cases: 325, 326
    ofp_print_bundle_add (ofp-print.c:3027)
    ofp_to_string__ (ofp-print.c:3410)
    ofp_to_string (ofp-print.c:3465)
    ofp_print (ofp-print.c:3497)
    ofctl_ofp_print (ovs-ofctl.c:3818)
    ovs_cmdl_run_command (command-line.c:121)
    main (ovs-ofctl.c:135)

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>
---
 lib/ofp-print.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ben Pfaff Jan. 4, 2016, 8:36 p.m. UTC | #1
On Thu, Dec 24, 2015 at 10:28:40AM -0800, William Tu wrote:
> Call ds_put_and_free_cstr instead of ds_put_cstr to free msg.
> Reported by test cases: 325, 326
>     ofp_print_bundle_add (ofp-print.c:3027)
>     ofp_to_string__ (ofp-print.c:3410)
>     ofp_to_string (ofp-print.c:3465)
>     ofp_print (ofp-print.c:3497)
>     ofctl_ofp_print (ovs-ofctl.c:3818)
>     ovs_cmdl_run_command (command-line.c:121)
>     main (ovs-ofctl.c:135)
> 
> Signed-off-by: William Tu <u9012063@gmail.com>
> Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
> Co-authored-by: Daniele Di Proietto <diproiettod@vmware.com>

Thanks, applied to master, branch-2.5, and branch-2.4.
diff mbox

Patch

diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 930b01a..61287ec 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -3026,7 +3026,7 @@  ofp_print_bundle_add(struct ds *s, const struct ofp_header *oh, int verbosity)
     ds_put_char(s, '\n');
     msg = ofp_to_string(badd.msg, ntohs(badd.msg->length), verbosity);
     if (msg) {
-        ds_put_cstr(s, msg);
+        ds_put_and_free_cstr(s, msg);
     }
 }