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
This commit is contained in:
Darryl L. Miles 2024-10-04 20:24:29 +01:00 committed by Tim Edwards
parent da80d5c75d
commit 55413d6b3a
1 changed files with 5 additions and 3 deletions

View File

@ -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);
}