From 63d86f5af852a175b8f4b61d1ef4c296a12294c2 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Fri, 17 Mar 2023 15:42:34 +0100 Subject: [PATCH] Prevent a crash in strchr Reported by KiCad Sentry --- src/frontend/inpc_probe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/frontend/inpc_probe.c b/src/frontend/inpc_probe.c index 4c547446b..7ef70ce93 100644 --- a/src/frontend/inpc_probe.c +++ b/src/frontend/inpc_probe.c @@ -1264,8 +1264,12 @@ void modprobenames(INPtables* tab) { char* name = GENinst->GENname; if (prefix("vcurr_", name)) { /* copy from char no. 6 to (and excluding) second colon */ + char* endname2; char* endname = strchr(name, ':'); - char* endname2 = strchr(endname + 1, ':'); + if (endname) + endname2 = strchr(endname + 1, ':'); + else /* not a single colon, something different? */ + continue; /* two-terminal device, one colon, copy all from char no. 6 to (and excluding) colon */ if (!endname2) { char* newname = copy_substring(name + 6, endname);