Add verify strdup return value logic.

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

Signed-off-by: Chengwen Feng <fengcheng...@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

Reply via email to