diff options
author | Jason Nader <jason@kayoway.com> | 2020-01-18 18:33:43 +0900 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-01-18 10:36:03 +0100 |
commit | a576bc27bf29e91ccf6659cafffeb6cd38a8d9f1 (patch) | |
tree | d6fcf025fd61e909855f84b1567cd7fc79d73aa5 | |
parent | 450b40c6356413628937dbcbba16bd7f1544111b (diff) |
Check argc>0 before strcasecmp. Should shortcircuit
-rw-r--r-- | sway/commands/move.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c index ceeab07c..cdbad13e 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -921,19 +921,13 @@ struct cmd_results *cmd_move(int argc, char **argv) { --argc; ++argv; } - if (strcasecmp(argv[0], "window") == 0 || - strcasecmp(argv[0], "container") == 0) { - --argc; - if (argc > 0) { - ++argv; - } + if (argc > 0 && (strcasecmp(argv[0], "window") == 0 || + strcasecmp(argv[0], "container") == 0)) { + --argc; ++argv; } - if (strcasecmp(argv[0], "to") == 0) { - --argc; - if (argc > 0) { - ++argv; - } + if (argc > 0 && strcasecmp(argv[0], "to") == 0) { + --argc; ++argv; } if (!argc) { |