From 89fa9354160307aecb2d60f4a9addaeecdd2db68 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Wed, 16 Oct 2024 10:20:51 +0100 Subject: [PATCH] grTk1.c: GrTkIconUpdate() potential -1 out-of-bound access SonarCloud Access of 'char' element in the region at index -1 This was not picked up, even though similar code was. --- graphics/grTk1.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/graphics/grTk1.c b/graphics/grTk1.c index ea31b786..ada54efa 100644 --- a/graphics/grTk1.c +++ b/graphics/grTk1.c @@ -1754,7 +1754,9 @@ GrTkIconUpdate(w, text) /* See Blt code */ class.res_class = "magic"; XSetClassHint( grXdpy, wind, &class); - if ((brack = strchr(text,'['))) + if (text == NULL) + return; + if ((brack = strchr(text,'[')) && brack != text) { brack--; *brack = 0;