Add a missing error message which causes an invalid layout name to crash.
authornicm <nicm@openbsd.org>
Thu, 2 Feb 2023 09:24:59 +0000 (09:24 +0000)
committernicm <nicm@openbsd.org>
Thu, 2 Feb 2023 09:24:59 +0000 (09:24 +0000)
usr.bin/tmux/layout-custom.c

index 53d49e4..1c1dd6b 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: layout-custom.c,v 1.21 2022/05/30 12:52:02 nicm Exp $ */
+/* $OpenBSD: layout-custom.c,v 1.22 2023/02/02 09:24:59 nicm Exp $ */
 
 /*
  * Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -162,8 +162,10 @@ layout_parse(struct window *w, const char *layout, char **cause)
        u_short                  csum;
 
        /* Check validity. */
-       if (sscanf(layout, "%hx,", &csum) != 1)
+       if (sscanf(layout, "%hx,", &csum) != 1) {
+               *cause = xstrdup("invalid layout");
                return (-1);
+       }
        layout += 5;
        if (csum != layout_checksum(layout)) {
                *cause = xstrdup("invalid layout");