mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 07:51:28 +00:00
criteria: fix crash when comparing NULL properties
For each following combinations of criteria & command below, the command would crash sway without the fix. It's particular about the __focused__ criteria, where the view matches part of the criteria but not the focused app, leading to a failure when calling `strcmp` with NULL. "xterm" is a non-wayland app (X11) and "kitty" is. Both are terminals. # "class" is specific to X11 # The view is X11 (xterm) leading to the criteria checking for the # focused app's class, leading to a crash for_window [class="__focused__"] floating enable exec kitty -e xterm # Similarly, crash as the focused app (xterm) has no app_id when the view has one for_window [app_id="__focused__"] floating enable exec xterm -e kitty # If the view has a title but not the focused app: NULL title will crash criteria checking for_window [title="__focused__"] floating enable exec xterm -title "" -e xterm
This commit is contained in:
parent
4583feee59
commit
b5cc11b226
|
@ -188,7 +188,7 @@ static bool criteria_matches_view(struct criteria *criteria,
|
|||
|
||||
switch (criteria->title->match_type) {
|
||||
case PATTERN_FOCUSED:
|
||||
if (focused && strcmp(title, view_get_title(focused))) {
|
||||
if (focused && lenient_strcmp(title, view_get_title(focused))) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -228,7 +228,7 @@ static bool criteria_matches_view(struct criteria *criteria,
|
|||
|
||||
switch (criteria->app_id->match_type) {
|
||||
case PATTERN_FOCUSED:
|
||||
if (focused && strcmp(app_id, view_get_app_id(focused))) {
|
||||
if (focused && lenient_strcmp(app_id, view_get_app_id(focused))) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -260,7 +260,7 @@ static bool criteria_matches_view(struct criteria *criteria,
|
|||
|
||||
switch (criteria->class->match_type) {
|
||||
case PATTERN_FOCUSED:
|
||||
if (focused && strcmp(class, view_get_class(focused))) {
|
||||
if (focused && lenient_strcmp(class, view_get_class(focused))) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue