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
This commit is contained in:
parent
c3eca8b8cc
commit
9fe9cedf42
@ -324,9 +324,17 @@ semicolon: EATSPACE();
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user