=================================================================== RCS file: /cvs/mandoc/roff.c,v retrieving revision 1.379 retrieving revision 1.382 diff -u -p -r1.379 -r1.382 --- mandoc/roff.c 2021/10/04 10:12:27 1.379 +++ mandoc/roff.c 2022/04/24 13:38:46 1.382 @@ -1,6 +1,6 @@ -/* $Id: roff.c,v 1.379 2021/10/04 10:12:27 schwarze Exp $ */ +/* $Id: roff.c,v 1.382 2022/04/24 13:38:46 schwarze Exp $ */ /* - * Copyright (c) 2010-2015, 2017-2020 Ingo Schwarze + * Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any @@ -861,6 +861,7 @@ void roff_man_free(struct roff_man *man) { roff_man_free1(man); + free(man->os_r); free(man); } @@ -1400,7 +1401,7 @@ roff_expand(struct roff *r, struct buf *buf, int ln, i term = '\0'; cp = stesc + 1; - if (*cp == 'E') + while (*cp == 'E') cp++; esct = cp; switch (*esct) { @@ -3869,8 +3870,9 @@ static int roff_shift(ROFF_ARGS) { struct mctx *ctx; - int levels, i; + int argpos, levels, i; + argpos = pos; levels = 1; if (buf->buf[pos] != '\0' && roff_evalnum(r, ln, buf->buf, &pos, &levels, 0) == 0) { @@ -3885,8 +3887,12 @@ roff_shift(ROFF_ARGS) ctx = r->mstack + r->mstackpos; if (levels > ctx->argc) { mandoc_msg(MANDOCERR_SHIFT, - ln, pos, "%d, but max is %d", levels, ctx->argc); + ln, argpos, "%d, but max is %d", levels, ctx->argc); levels = ctx->argc; + } + if (levels < 0) { + mandoc_msg(MANDOCERR_ARG_NEG, ln, argpos, "shift %d", levels); + levels = 0; } if (levels == 0) return ROFF_IGN;