grX11su1.c: GrX11IconUpdate() potential -1 out-of-bound access

SonarCloud
Access of 'char' element in the region at index -1
https://sonarcloud.io/project/issues?open=AZJB163RNGfDNup0Ri4r&id=dlmiles_magic
This commit is contained in:
Darryl L. Miles 2024-10-16 10:23:21 +01:00 committed by Tim Edwards
parent 3a35d4d28d
commit 114ddf1b0c
1 changed files with 4 additions and 2 deletions

View File

@ -1441,7 +1441,9 @@ GrX11IconUpdate(w,text)
class.res_name = "magic";
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;
@ -1450,7 +1452,7 @@ GrX11IconUpdate(w,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);
}