From a576bc27bf29e91ccf6659cafffeb6cd38a8d9f1 Mon Sep 17 00:00:00 2001 From: Jason Nader Date: Sat, 18 Jan 2020 18:33:43 +0900 Subject: [PATCH] Check argc>0 before strcasecmp. Should shortcircuit --- sway/commands/move.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/sway/commands/move.c b/sway/commands/move.c index ceeab07c2..cdbad13e1 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) {