summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>1998-12-07 05:35:54 +0000
committerarchie <archie@FreeBSD.org>1998-12-07 05:35:54 +0000
commit70bef8d2090b5aa52af350b210be8d20a41767dc (patch)
treee36f0d3652ab9a84f59614d9c1741bfd4ebb3515 /usr.bin/sed
parent5fa68e57c09b226cc9be538b36c4c52b94b7ab4e (diff)
downloadFreeBSD-src-70bef8d2090b5aa52af350b210be8d20a41767dc.zip
FreeBSD-src-70bef8d2090b5aa52af350b210be8d20a41767dc.tar.gz
Fix brokenness compiling "s/pat/subst/" when length of subst is >= 4090 chars.
PR: bin/7939
Diffstat (limited to 'usr.bin/sed')
-rw-r--r--usr.bin/sed/compile.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c
index 1c9b82b..bf0b56f 100644
--- a/usr.bin/sed/compile.c
+++ b/usr.bin/sed/compile.c
@@ -40,7 +40,7 @@
static char sccsid[] = "@(#)compile.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: compile.c,v 1.9 1997/08/11 07:20:58 charnier Exp $";
+ "$Id: compile.c,v 1.10 1998/09/22 18:39:47 brian Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -483,7 +483,10 @@ compile_subst(p, s)
} else if (*p == '&' || *p == '\\')
*sp++ = '\\';
} else if (*p == c) {
- p++;
+ if (*++p == '\0') {
+ if (cu_fgets(lbuf, sizeof(lbuf)))
+ p = lbuf;
+ }
*sp++ = '\0';
size += sp - op;
s->new = xrealloc(text, size);
@@ -498,7 +501,7 @@ compile_subst(p, s)
size += sp - op;
if (asize - size < _POSIX2_LINE_MAX + 1) {
asize *= 2;
- text = xmalloc(asize);
+ text = xrealloc(text, asize);
}
} while (cu_fgets(p = lbuf, sizeof(lbuf)));
errx(1, "%lu: %s: unterminated substitute in regular expression",
OpenPOWER on IntegriCloud