[PATCH GnuPG 4/7] common: check strchr for null

Sam James sam at gentoo.org
Wed Jan 28 13:35:04 CET 2026


* common/asshelp.c (start_new_service): Check if strchr
  result is NULL.

--

We check program_args later on before use, so it's enough to just
conditionally check-then-deref-and-increment, because later on, we
won't use it otherwise.

Found by GCC's -fanalyzer.

Signed-off-by: Sam James <sam at gentoo.org>
---
 common/asshelp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/asshelp.c b/common/asshelp.c
index 82a7b11d0..b119c249c 100644
--- a/common/asshelp.c
+++ b/common/asshelp.c
@@ -486,7 +486,8 @@ start_new_service (assuan_context_t *r_ctx,
               return tmperr;
             }
           p = strchr (program, '|');
-          *p++ = 0;
+          if (p)
+              *p++ = 0;
           program_arg = p;
         }
 
-- 
2.52.0




More information about the Gnupg-devel mailing list