From: ohilyard@iol.unh.edu To: olivier.matz@6wind.com Cc: dev@dpdk.org, david.marchand@redhat.com, stable@dpdk.org, Owen Hilyard <ohilyard@iol.unh.edu> Subject: [dpdk-stable] [PATCH] tests/cmdline: fix memory leaks Date: Wed, 16 Jun 2021 14:07:24 -0400 Message-ID: <20210616180724.355217-1-ohilyard@iol.unh.edu> (raw) In-Reply-To: <20210616162553.350074-1-ohilyard@iol.unh.edu> From: Owen Hilyard <ohilyard@iol.unh.edu> Fixes for a few memory leaks in the cmdline_autotest unit test. All of the leaks were related to not freeing the commandline struct after testing had completed. Fixes: dbb860e03e ("cmdline: tests") Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu> Reviewed-by: David Marchand <david.marchand@redhat.com> --- app/test/test_cmdline_lib.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/app/test/test_cmdline_lib.c b/app/test/test_cmdline_lib.c index bd72df0da..19228c9a5 100644 --- a/app/test/test_cmdline_lib.c +++ b/app/test/test_cmdline_lib.c @@ -71,10 +71,12 @@ test_cmdline_parse_fns(void) if (cmdline_complete(cl, "buffer", &i, NULL, sizeof(dst)) >= 0) goto error; + cmdline_free(cl); return 0; error: printf("Error: function accepted null parameter!\n"); + cmdline_free(cl); return -1; } @@ -140,32 +142,43 @@ static int test_cmdline_socket_fns(void) { cmdline_parse_ctx_t ctx; + struct cmdline *cl; - if (cmdline_stdin_new(NULL, "prompt") != NULL) + cl = cmdline_stdin_new(NULL, "prompt"); + if (cl != NULL) goto error; - if (cmdline_stdin_new(&ctx, NULL) != NULL) + cl = cmdline_stdin_new(&ctx, NULL); + if (cl != NULL) goto error; - if (cmdline_file_new(NULL, "prompt", "/dev/null") != NULL) + cl = cmdline_file_new(NULL, "prompt", "/dev/null"); + if (cl != NULL) goto error; - if (cmdline_file_new(&ctx, NULL, "/dev/null") != NULL) + cl = cmdline_file_new(&ctx, NULL, "/dev/null"); + if (cl != NULL) goto error; - if (cmdline_file_new(&ctx, "prompt", NULL) != NULL) + cl = cmdline_file_new(&ctx, "prompt", NULL); + if (cl != NULL) goto error; - if (cmdline_file_new(&ctx, "prompt", "-/invalid/~/path") != NULL) { + cl = cmdline_file_new(&ctx, "prompt", "-/invalid/~/path"); + if (cl != NULL) { printf("Error: succeeded in opening invalid file for reading!"); + cmdline_free(cl); return -1; } - if (cmdline_file_new(&ctx, "prompt", "/dev/null") == NULL) { + cl = cmdline_file_new(&ctx, "prompt", "/dev/null"); + if (cl == NULL) { printf("Error: failed to open /dev/null for reading!"); + cmdline_free(cl); return -1; } /* void functions */ cmdline_stdin_exit(NULL); - + cmdline_free(cl); return 0; error: printf("Error: function accepted null parameter!\n"); + cmdline_free(cl); return -1; } @@ -198,6 +211,7 @@ test_cmdline_fns(void) cmdline_interact(NULL); cmdline_quit(NULL); + cmdline_free(cl); return 0; error: -- 2.30.2
next parent reply other threads:[~2021-06-16 18:07 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <20210616162553.350074-1-ohilyard@iol.unh.edu> 2021-06-16 18:07 ` ohilyard [this message] 2021-06-23 8:43 ` Olivier Matz 2021-06-23 18:06 ` [dpdk-stable] [PATCH v3] " ohilyard 2021-06-24 12:07 ` Olivier Matz 2021-06-24 13:24 ` David Marchand 2021-06-24 13:25 ` David Marchand 2021-08-11 12:55 [dpdk-stable] [PATCH 19.11] " Owen Hilyard 2021-08-12 19:44 ` [dpdk-stable] [PATCH] " ohilyard 2021-08-16 8:59 ` Christian Ehrhardt 2021-08-16 12:05 ` ohilyard 2021-08-16 12:06 ` Owen Hilyard
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210616180724.355217-1-ohilyard@iol.unh.edu \ --to=ohilyard@iol.unh.edu \ --cc=david.marchand@redhat.com \ --cc=dev@dpdk.org \ --cc=olivier.matz@6wind.com \ --cc=stable@dpdk.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
patches for DPDK stable branches This inbox may be cloned and mirrored by anyone: git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \ stable@dpdk.org public-inbox-index stable Example config snippet for mirrors. Newsgroup available over NNTP: nntp://inbox.dpdk.org/inbox.dpdk.stable AGPL code for this site: git clone https://public-inbox.org/public-inbox.git