[ovs-dev,1/1] ovn-nbctl: fix memory leak
diff mbox series

Message ID 1562154640-31792-1-git-send-email-damjan.skvarc@gmail.com
State New
Headers show
Series
  • [ovs-dev,1/1] ovn-nbctl: fix memory leak
Related show

Commit Message

Damijan Skvarc July 3, 2019, 11:50 a.m. UTC
Patch is mostly intended to prevent valgrind to report memory leak issues
while running unit tests. Otherwise it does not benefit anything since 
the application exits immediately after freeing the memory.

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
---
 ovn/utilities/ovn-nbctl.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Ben Pfaff July 3, 2019, 4:44 p.m. UTC | #1
On Wed, Jul 03, 2019 at 01:50:40PM +0200, Damijan Skvarc wrote:
> Patch is mostly intended to prevent valgrind to report memory leak issues
> while running unit tests. Otherwise it does not benefit anything since 
> the application exits immediately after freeing the memory.
> 
> Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>

Thanks, applied to master.

Patch
diff mbox series

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index e86ab7f..98a8faa 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -156,6 +156,7 @@  main(int argc, char *argv[])
     char *error_s = ovs_cmdl_parse_all(argc, argv, get_all_options(),
                                        &parsed_options, &n_parsed_options);
     if (error_s) {
+        free(args);
         ctl_fatal("%s", error_s);
     }
 
@@ -181,6 +182,7 @@  main(int argc, char *argv[])
     bool daemon_mode = false;
     if (get_detach()) {
         if (argc != optind) {
+            free(args);
             ctl_fatal("non-option arguments not supported with --detach "
                       "(use --help for help)");
         }
@@ -203,6 +205,7 @@  main(int argc, char *argv[])
         error = ctl_parse_commands(argc - optind, argv + optind,
                                    &local_options, &commands, &n_commands);
         if (error) {
+            free(args);
             ctl_fatal("%s", error);
         }
         VLOG(ctl_might_write_to_db(commands, n_commands) ? VLL_INFO : VLL_DBG,
@@ -212,11 +215,13 @@  main(int argc, char *argv[])
 
         error = run_prerequisites(commands, n_commands, idl);
         if (error) {
+            free(args);
             ctl_fatal("%s", error);
         }
 
         error = main_loop(args, commands, n_commands, idl, NULL);
         if (error) {
+            free(args);
             ctl_fatal("%s", error);
         }