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,7 +1076,9 @@ GrOGLIconUpdate(w,text)
class.res_class = "magic"; class.res_class = "magic";
XSetClassHint( grXdpy, wind, &class); XSetClassHint( grXdpy, wind, &class);
if (brack = strchr(text,'[')) if (text == NULL)
return;
if ((brack = strchr(text,'[')) && brack != text)
{ {
brack--; brack--;
*brack = 0; *brack = 0;
@ -1085,7 +1087,7 @@ GrOGLIconUpdate(w,text)
*brack = ' '; *brack = ' ';
return; return;
} }
if (brack = strrchr(text,' ')) text = brack+1; if ((brack = strrchr(text,' '))) text = brack+1;
XSetIconName(grXdpy,wind,text); XSetIconName(grXdpy,wind,text);
XStoreName(grXdpy,wind,text); XStoreName(grXdpy,wind,text);
} }