echo: fix SEGV when run with no args

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2011-02-15 18:35:54 +01:00
parent 28556b95fe
commit 4fdb67cc65

View File

@ -97,7 +97,7 @@ int echo_main(int argc UNUSED_PARAM, char **argv)
buflen += strlen(arg) + 1;
pp++;
}
out = buffer = xmalloc(buflen);
out = buffer = xmalloc(buflen + 1); /* +1 is needed for "no args" case */
while ((arg = *argv) != NULL) {
int c;