From 20001eb2e24e4ed036e6fc8a56b3d644856de4eb Mon Sep 17 00:00:00 2001 From: stefanf Date: Wed, 28 May 2008 21:44:32 +0000 Subject: Fix checking if a variable name is LINENO. As STPUTC changes the pointer if it needs to enlarge the buffer, we must not keep a pointer to the beginning. PR: ports/123879 --- bin/sh/parser.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'bin/sh/parser.c') diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 75b4cac..86f50fc 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -1188,6 +1188,7 @@ parsesub: { int bracketed_name = 0; /* used to handle ${[0-9]*} variables */ int i; int linno; + int length; c = pgetc(); if (c != '(' && c != '{' && (is_eof(c) || !is_name(c)) && @@ -1220,12 +1221,14 @@ parsesub: { subtype = 0; } if (!is_eof(c) && is_name(c)) { - p = out; + length = 0; do { STPUTC(c, out); c = pgetc(); + length++; } while (!is_eof(c) && is_in_name(c)); - if (out - p == 6 && strncmp(p, "LINENO", 6) == 0) { + if (length == 6 && + strncmp(out - length, "LINENO", length) == 0) { /* Replace the variable name with the * current line number. */ linno = plinno; -- cgit v1.1