| Message ID | 1491601426-77274-7-git-send-email-yihung.wei@gmail.com |
|---|---|
| State | Accepted |
| Headers | show |
On Fri, Apr 07, 2017 at 02:43:45PM -0700, Yi-Hung Wei wrote: > In testcase "2319: ovn-nbctl - NATs", valgrind reports a memory leak with > the following code stack. > xmalloc (util.c:112) > xvasprintf (util.c:176) > xasprintf (util.c:272) > nbctl_lr_nat_list (ovn-nbctl.c:2400) > do_nbctl (ovn-nbctl.c:3121) > main (ovn-nbctl.c:142) > > Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Good catch, thank you! I applied this to master.
diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 598f502af5b4..b58d4eb6cb8d 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -2399,7 +2399,7 @@ nbctl_lr_nat_list(struct ctl_context *ctx) struct smap lr_nats = SMAP_INITIALIZER(&lr_nats); for (size_t i = 0; i < lr->n_nat; i++) { const struct nbrec_nat *nat = lr->nat[i]; - const char *key = xasprintf("%-17.13s%s", nat->type, nat->external_ip); + char *key = xasprintf("%-17.13s%s", nat->type, nat->external_ip); if (nat->external_mac && nat->logical_port) { smap_add_format(&lr_nats, key, "%-22.18s%-21.17s%s", nat->logical_ip, nat->external_mac, @@ -2407,6 +2407,7 @@ nbctl_lr_nat_list(struct ctl_context *ctx) } else { smap_add_format(&lr_nats, key, "%s", nat->logical_ip); } + free(key); } const struct smap_node **nodes = smap_sort(&lr_nats);
In testcase "2319: ovn-nbctl - NATs", valgrind reports a memory leak with the following code stack. xmalloc (util.c:112) xvasprintf (util.c:176) xasprintf (util.c:272) nbctl_lr_nat_list (ovn-nbctl.c:2400) do_nbctl (ovn-nbctl.c:3121) main (ovn-nbctl.c:142) Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> --- ovn/utilities/ovn-nbctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)