From 04029327665ca3c97ae07cae698d5df760f2b68e Mon Sep 17 00:00:00 2001 From: obrien Date: Wed, 13 Oct 2010 23:29:09 +0000 Subject: Do not assume in growstackstr() that a "precious" character will be immediately written into the stack after the call. Instead let the caller manage the "space left". Previously, growstackstr()'s assumption causes problems with STACKSTRNUL() where we want to be able to turn a stack into a C string, and later pretend the NUL is not there. This fixes a bug in STACKSTRNUL() (that grew the stack) where: 1. STADJUST() called after a STACKSTRNUL() results in an improper adjust. This can be seen in ${var%pattern} and ${var%%pattern} evaluation. 2. Memory leak in STPUTC() called after a STACKSTRNUL(). Reviewed by: jilles --- tools/regression/bin/sh/expansion/trim4.0 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tools/regression/bin/sh/expansion/trim4.0 (limited to 'tools') diff --git a/tools/regression/bin/sh/expansion/trim4.0 b/tools/regression/bin/sh/expansion/trim4.0 new file mode 100644 index 0000000..1000bd3 --- /dev/null +++ b/tools/regression/bin/sh/expansion/trim4.0 @@ -0,0 +1,15 @@ +# $FreeBSD$ + +v1=/homes/SOME_USER +v2= +v3=C123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + +# Trigger bug in VSTRIMRIGHT processing STADJUST() call in expand.c:subevalvar() +while [ ${#v2} -lt 2000 ]; do + v4="${v2} ${v1%/*} $v3" + if [ ${#v4} -ne $((${#v2} + ${#v3} + 8)) ]; then + echo bad: ${#v4} -ne $((${#v2} + ${#v3} + 8)) + fi + v2=x$v2 + v3=y$v3 +done -- cgit v1.1