From 26689a7c8103e9a2cb44f862988eaabaa6020411 Mon Sep 17 00:00:00 2001 From: tg Date: Fri, 11 Nov 2016 20:53:15 +0000 Subject: [PATCH] just 'print -c' outputs not even a newline; plug a memleak while here --- funcs.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/funcs.c b/funcs.c index 64ebf84..55aa2a7 100644 --- a/funcs.c +++ b/funcs.c @@ -38,7 +38,7 @@ #endif #endif -__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.314 2016/11/11 20:14:17 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.315 2016/11/11 20:53:15 tg Exp $"); #if HAVE_KILLPG /* @@ -449,12 +449,17 @@ c_print(const char **wp) wp += builtin_opt.optind; } + if (po.col) { + if (*wp == NULL) + return (0); + + XPinit(words, 16); + } + Xinit(xs, xp, 128, ATEMP); if (*wp == NULL) goto print_no_arg; - if (po.col) - XPinit(words, 16); print_read_arg: if (po.chars) { while (*wp != NULL) { @@ -548,7 +553,6 @@ c_print(const char **wp) if (po.hist) { Xput(xs, xp, '\0'); histsave(&source->line, Xstring(xs, xp), HIST_STORE, false); - Xfree(xs, xp); } else { size_t len = Xlength(xs, xp); @@ -588,6 +592,7 @@ c_print(const char **wp) if (po.copipe) restore_pipe(); } + Xfree(xs, xp); return (c); }