From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 105A9A0C43 for ; Wed, 16 Jun 2021 20:07:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D93AC4067A; Wed, 16 Jun 2021 20:07:29 +0200 (CEST) Received: from mail-ua1-f98.google.com (mail-ua1-f98.google.com [209.85.222.98]) by mails.dpdk.org (Postfix) with ESMTP id 1D9A84067A for ; Wed, 16 Jun 2021 20:07:29 +0200 (CEST) Received: by mail-ua1-f98.google.com with SMTP id r4so195870uap.8 for ; Wed, 16 Jun 2021 11:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OGyFlzWCfQIxD4ZcKldWiRHStRmEHk5zBxu1qYGJyks=; b=GvzRGkscJoZfgi0APV855Bdf+ccmlhtWIh4LzVzKqO4g3AUf11df0evJ30NbUsNz7g SblsrV6KkYQnNMueaTkglaHn93ok9791v/ZNNSJbgIqKbppuj7TVUGfbN+/rGdzK77si SJs9kJC2vOgm/yf/Mm6qatpVELeLazBjxSUoY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OGyFlzWCfQIxD4ZcKldWiRHStRmEHk5zBxu1qYGJyks=; b=j+kdD+tTexpxLSc6xQU4nn1Jz8sr26sIh+5ub0DEjShjEAZqDK7xGIfEV+zoYTI251 oloxmZZRanQUSQ8rkTZL+fLZ8efVwvqfhg3Sie6+S/3iNJ9hifD++JE0F803ki5b7scS JzM5h4i8rl442u8RkLm7xH+oFW8IXsadJ5qJ5wliRtMMzsqSPd01ziuqTUQwiTxLDW4c 5r2x52o2cCtF6POUUHnCCOpRPJdxACzbeOcaKNl0WKhzsZAyxpAKtF3YJKf5VJ+fGnaJ xFdhqDWidj6EOLF39V+MoC3Ta/qvC6QXqdgatkYr6PJHXlCkN8PFYYCW8qN+2FAhjloM tezA== X-Gm-Message-State: AOAM531i/Vhk1IbLI8rPmDxp9ckB34UE4lE2D4A3/kc90SmJl9Ouyt9h 5ztoLlHdtTyg3ST99g1q1KUXpdx978f5icd94jE7AqGfgWqquQ== X-Google-Smtp-Source: ABdhPJwnf5bz1JjStqCGUnVPzi89fBeO+vYD4u7r7Rza2LF4a/MmpYjktW4LtXybZgbo7/3c7kUVpRGZh92S X-Received: by 2002:a9f:374c:: with SMTP id a12mr994122uae.91.1623866847891; Wed, 16 Jun 2021 11:07:27 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id d72sm1137530vkf.7.2021.06.16.11.07.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jun 2021 11:07:27 -0700 (PDT) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1220:5e2f:685e:142b:54c3]) by postal.iol.unh.edu (Postfix) with ESMTP id 39F21605246B; Wed, 16 Jun 2021 14:07:27 -0400 (EDT) From: ohilyard@iol.unh.edu To: olivier.matz@6wind.com Cc: dev@dpdk.org, david.marchand@redhat.com, stable@dpdk.org, Owen Hilyard Date: Wed, 16 Jun 2021 14:07:24 -0400 Message-Id: <20210616180724.355217-1-ohilyard@iol.unh.edu> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210616162553.350074-1-ohilyard@iol.unh.edu> References: <20210616162553.350074-1-ohilyard@iol.unh.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH] tests/cmdline: fix memory leaks X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Owen Hilyard 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 Reviewed-by: David Marchand --- 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