Variable nb_jobs, which may be zero, is used as a denominator.

This patch fixed it.

Fixes: f5cffb7eb7fb ("app/regex: read data file once at startup")
Cc: [email protected]

Signed-off-by: Min Hu (Connor) <[email protected]>
---
 app/test-regex/main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/app/test-regex/main.c b/app/test-regex/main.c
index 8e665df..b49fa88 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -725,9 +725,11 @@ main(int argc, char **argv)
        if (data_len <= 0)
                rte_exit(EXIT_FAILURE, "Error, can't read file, or file is 
empty.\n");
 
-       job_len = data_len / nb_jobs;
-       if (job_len == 0)
-               rte_exit(EXIT_FAILURE, "Error, To many jobs, for the given 
input.\n");
+       if (!nb_jobs) {
+               job_len = data_len / nb_jobs;
+               if (job_len == 0)
+                       rte_exit(EXIT_FAILURE, "Error, To many jobs, for the 
given input.\n");
+       }
 
        if (job_len > nb_max_payload)
                rte_exit(EXIT_FAILURE, "Error, not enough jobs to cover 
input.\n");
-- 
2.7.4

Reply via email to