Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Nov 2008 01:10:21 +0000 (UTC)
From:      Hiroki Sato <hrs@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r184777 - head/usr.bin/sed
Message-ID:  <200811090110.mA91ALkc026621@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811090110.mA91ALkc026621>