svn commit: r184777 - head/usr.bin/sed
Hiroki Sato
hrs at FreeBSD.org
Sat Nov 8 17:10:21 PST 2008
Author: hrs
Date: Sun Nov 9 01:10:21 2008
New Revision: 184777
URL: http://svn.freebsd.org/changeset/base/184777
Log:
Add workaround for a back reference when no corresponding
parenthesized subexpression is defined. For example, the
following command line caused unexpected behavior like
segmentation fault:
% echo test | sed -e 's/test/\1/'
PR: bin/126682
MFC after: 1 week
Modified:
head/usr.bin/sed/compile.c
Modified: head/usr.bin/sed/compile.c
==============================================================================
--- head/usr.bin/sed/compile.c Sun Nov 9 00:49:36 2008 (r184776)
+++ head/usr.bin/sed/compile.c Sun Nov 9 01:10:21 2008 (r184777)
@@ -324,9 +324,17 @@ nonsel: /* Now parse the command */
if (p == NULL)
errx(1,
"%lu: %s: unterminated substitute pattern", linenum, fname);
+
+ /* Compile RE with no case sensitivity temporarily */
+ if (*re == '\0')
+ cmd->u.s->re = NULL;
+ else
+ cmd->u.s->re = compile_re(re, 0);
--p;
p = compile_subst(p, cmd->u.s);
p = compile_flags(p, cmd->u.s);
+
+ /* Recompile RE with case sensitivity from "I" flag if any */
if (*re == '\0')
cmd->u.s->re = NULL;
else
More information about the svn-src-head
mailing list