diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2020-02-10 13:05:16 +0100 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2020-02-10 13:05:16 +0100 |
| commit | 2baf7beb92c45c19e20d1dca54bff7a0c243703f (patch) | |
| tree | 8c8b57327e880f38651a376d1f8d8a88e1db204f | |
| parent | 65fbd257be3bcbf5bf2e9b0068ddc76c012c84bf (diff) | |
Avoid calling strcmp on nullptr
The function group_handler may get a nullptr as `new_group`. If that's
the case, return true, as if `new_group` was the empty string.
Also make the conversion to bool explicit when calling `strcmp`.
| -rw-r--r-- | swaybar/tray/icon.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/swaybar/tray/icon.c b/swaybar/tray/icon.c index 8adefda6..d0c3fa56 100644 --- a/swaybar/tray/icon.c +++ b/swaybar/tray/icon.c @@ -89,7 +89,10 @@ static bool validate_icon_theme(struct icon_theme *theme) { static bool group_handler(char *old_group, char *new_group, struct icon_theme *theme) { if (!old_group) { // first group must be "Icon Theme" - return strcmp(new_group, "Icon Theme"); + if (!new_group) { + return true; + } + return strcmp(new_group, "Icon Theme") != 0; } if (strcmp(old_group, "Icon Theme") == 0) { |
