From 45c41df969405fecaf0b0847fda703175b8296e4 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 14 Jun 2017 07:42:41 +0000 Subject: [PATCH] Don't overwrite error message when it is available in cmd_string_parse. Reported by Jimi Damon in GitHub issue 975. --- usr.bin/tmux/cmd-string.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/usr.bin/tmux/cmd-string.c b/usr.bin/tmux/cmd-string.c index a86181e3a66..968d303f356 100644 --- a/usr.bin/tmux/cmd-string.c +++ b/usr.bin/tmux/cmd-string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-string.c,v 1.28 2017/01/24 19:53:37 nicm Exp $ */ +/* $OpenBSD: cmd-string.c,v 1.29 2017/06/14 07:42:41 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -159,21 +159,19 @@ cmd_string_parse(const char *s, const char *file, u_int line, char **cause) char **argv; *cause = NULL; - if (cmd_string_split(s, &argc, &argv) != 0) - goto error; + if (cmd_string_split(s, &argc, &argv) != 0) { + xasprintf(cause, "invalid or unknown command: %s", s); + return (NULL); + } if (argc != 0) { cmdlist = cmd_list_parse(argc, argv, file, line, cause); if (cmdlist == NULL) { cmd_free_argv(argc, argv); - goto error; + return (NULL); } } cmd_free_argv(argc, argv); return (cmdlist); - -error: - xasprintf(cause, "invalid or unknown command: %s", s); - return (NULL); } static void -- 2.20.1