NetBSD 1.0 PATCH #6 INDEX DESCRIPTION ----- ----------- patch_06 Fix core dump on end of group. Affects: src/usr.bin/sed/compile.c diff -c src/usr.bin/sed/compile.c:1.11 src/usr.bin/sed/compile.c:1.11.2.1 *** src/usr.bin/sed/compile.c:1.11 Fri Dec 2 18:47:24 1994 --- src/usr.bin/sed/compile.c Fri Dec 2 18:47:24 1994 *************** *** 37,43 **** #ifndef lint /* from: static char sccsid[] = "@(#)compile.c 8.1 (Berkeley) 6/6/93"; */ ! static char *rcsid = "$Id: compile.c,v 1.11 1994/04/17 04:19:27 alm Exp $"; #endif /* not lint */ #include --- 37,43 ---- #ifndef lint /* from: static char sccsid[] = "@(#)compile.c 8.1 (Berkeley) 6/6/93"; */ ! static char *rcsid = "$Id: compile.c,v 1.11.2.1 1994/11/29 04:19:15 cgd Exp $"; #endif /* not lint */ #include *************** *** 177,183 **** cmd->nonsel = cmd->inrange = 0; /* First parse the addresses */ naddr = 0; - cmd->a1 = cmd->a2 = NULL; /* Valid characters to start an address */ #define addrchar(c) (strchr("0123456789/\\$", (c))) --- 177,182 ---- *************** *** 187,202 **** p = compile_addr(p, cmd->a1); EATSPACE(); /* EXTENSION */ if (*p == ',') { - naddr++; p++; EATSPACE(); /* EXTENSION */ cmd->a2 = xmalloc(sizeof(struct s_addr)); p = compile_addr(p, cmd->a2); ! } ! } nonsel: /* Now parse the command */ - EATSPACE(); if (!*p) err(COMPILE, "command expected"); cmd->code = *p; --- 186,203 ---- p = compile_addr(p, cmd->a1); EATSPACE(); /* EXTENSION */ if (*p == ',') { p++; EATSPACE(); /* EXTENSION */ + naddr++; cmd->a2 = xmalloc(sizeof(struct s_addr)); p = compile_addr(p, cmd->a2); ! EATSPACE(); ! } else ! cmd->a2 = 0; ! } else ! cmd->a1 = cmd->a2 = 0; nonsel: /* Now parse the command */ if (!*p) err(COMPILE, "command expected"); cmd->code = *p; *************** *** 210,217 **** "command %c expects up to %d address(es), found %d", *p, fp->naddr, naddr); switch (fp->args) { case NONSEL: /* ! */ - cmd->nonsel = ! cmd->nonsel; p++; goto nonsel; case GROUP: /* { */ p++; --- 211,219 ---- "command %c expects up to %d address(es), found %d", *p, fp->naddr, naddr); switch (fp->args) { case NONSEL: /* ! */ p++; + EATSPACE(); + cmd->nonsel = ! cmd->nonsel; goto nonsel; case GROUP: /* { */ p++; *************** *** 223,228 **** --- 225,236 ---- *compile_stream("}", &cmd->u.c, p) = cmd2; cmd->next = cmd2; link = &cmd2->next; + /* + * Short-circuit command processing, since end of + * group is really just a noop. + */ + cmd2->nonsel = 1; + cmd2->a1 = cmd2->a2 = 0; break; case EMPTY: /* d D g G h H l n N p P q x = \0 */ p++;