From d7bd15792ea3d2613aa5a0b09d948dc2ef77dfcf Mon Sep 17 00:00:00 2001 From: lingsheng Date: Wed, 27 Jan 2021 15:00:32 +0800 Subject: [PATCH] Add check for ports to avoid Segmentation fault --- tools/umax_pp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/umax_pp.c b/tools/umax_pp.c index 7b127e3..00ffea9 100644 --- a/tools/umax_pp.c +++ b/tools/umax_pp.c @@ -355,12 +355,15 @@ main (int argc, char **argv) if (rc != 1) { ports = sanei_parport_find_port (); - i = 0; - rc = 0; - while ((ports[i] != NULL) && (rc != 1)) + if (ports != NULL) { - rc = sanei_umax_pp_initPort (strtol (ports[i], NULL, 16), NULL); - i++; + i = 0; + rc = 0; + while ((ports[i] != NULL) && (rc != 1)) + { + rc = sanei_umax_pp_initPort (strtol (ports[i], NULL, 16), NULL); + i++; + } } } if (rc != 1) -- 2.23.0