Skip to content

Commit

Permalink
Check argc>0 before strcasecmp. Should shortcircuit
Browse files Browse the repository at this point in the history
  • Loading branch information
ammgws authored and emersion committed Jan 18, 2020
1 parent 450b40c commit a576bc2
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions sway/commands/move.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a576bc2

Please sign in to comment.