From 797e18658d422e8b62d08dfd200ec9bf0a06acc4 Mon Sep 17 00:00:00 2001 From: Daniel Hartmeier Date: Wed, 27 Feb 2002 19:37:10 +0000 Subject: Fix three off-by-one errors. ok espie@, millert@, miod@ --- bin/ksh/tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/ksh/tree.c b/bin/ksh/tree.c index bf8e879ec17..e412790b7f7 100644 --- a/bin/ksh/tree.c +++ b/bin/ksh/tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tree.c,v 1.9 1999/07/14 13:37:24 millert Exp $ */ +/* $OpenBSD: tree.c,v 1.10 2002/02/27 19:37:09 dhartmei Exp $ */ /* * command tree climbing @@ -508,7 +508,7 @@ tcopy(t, ap) for (tw = t->vars; *tw++ != NULL; ) ; rw = r->vars = (char **) - alloc((int)(tw - t->vars) * sizeof(*tw), ap); + alloc((tw - t->vars + 1) * sizeof(*tw), ap); for (tw = t->vars; *tw != NULL; ) *rw++ = wdcopy(*tw++, ap); *rw = NULL; @@ -520,7 +520,7 @@ tcopy(t, ap) for (tw = t->args; *tw++ != NULL; ) ; rw = r->args = (char **) - alloc((int)(tw - t->args) * sizeof(*tw), ap); + alloc((tw - t->args + 1) * sizeof(*tw), ap); for (tw = t->args; *tw != NULL; ) *rw++ = wdcopy(*tw++, ap); *rw = NULL; @@ -681,7 +681,7 @@ iocopy(iow, ap) for (ior = iow; *ior++ != NULL; ) ; - ior = (struct ioword **) alloc((int)(ior - iow) * sizeof(*ior), ap); + ior = (struct ioword **) alloc((ior - iow + 1) * sizeof(*ior), ap); for (i = 0; iow[i] != NULL; i++) { register struct ioword *p, *q; -- cgit v1.2.3