Do not read past the end of the argument string if it is empty.

This commit is contained in:
nicm 2019-05-28 18:30:30 +00:00 committed by Nicholas Marriott
parent 8d137233a9
commit 7eeb479705

View File

@ -210,6 +210,8 @@ args_escape(const char *s)
char *escaped, *result;
int flags;
if (*s == '\0')
return (xstrdup(s));
if ((strchr(quoted, s[0]) != NULL || s[0] == '~') && s[1] == '\0') {
xasprintf(&escaped, "\\%c", s[0]);
return (escaped);