From 55413d6b3ad876ff96ddf7e16331a1e872f9ec27 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Fri, 4 Oct 2024 20:24:29 +0100 Subject: [PATCH] grOGL1.c: GrOGLIconUpdate() potential -1 out-of-bound access SonarCloud Access of 'char' element in the region at index -1 https://sonarcloud.io/project/issues?open=AZJB16z6NGfDNup0Rist&id=dlmiles_magic --- graphics/grOGL1.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/graphics/grOGL1.c b/graphics/grOGL1.c index fd86c51c..9540c9d8 100644 --- a/graphics/grOGL1.c +++ b/graphics/grOGL1.c @@ -1076,16 +1076,18 @@ GrOGLIconUpdate(w,text) class.res_class = "magic"; XSetClassHint( grXdpy, wind, &class); - if (brack = strchr(text,'[')) + if (text == NULL) + return; + if ((brack = strchr(text,'[')) && brack != text) { - brack--; + brack--; *brack = 0; XSetIconName(grXdpy,wind,text); XStoreName(grXdpy,wind,text); *brack = ' '; return; } - if (brack = strrchr(text,' ')) text = brack+1; + if ((brack = strrchr(text,' '))) text = brack+1; XSetIconName(grXdpy,wind,text); XStoreName(grXdpy,wind,text); }