[PATCH v2 14/16] app/testpmd: verify strdup return value

Chengwen Feng fengchengwen at huawei.com
Fri Nov 10 11:01:15 CET 2023


Add verify strdup return value logic.

Fixes: 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")
Cc: stable at dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
---
 app/test-pmd/cmdline.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 912bf3355c..904c04d466 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3528,6 +3528,8 @@ parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
 
 	nb_item = 0;
 	char *str2 = strdup(str);
+	if (str2 == NULL)
+		return nb_item;
 	cur = strtok_r(str2, ",", &tmp);
 	while (cur != NULL) {
 		parsed_items[nb_item] = get_ptype(cur);
-- 
2.17.1



More information about the dev mailing list