=================================================================== RCS file: /cvs/mandoc/read.c,v retrieving revision 1.159 retrieving revision 1.161 diff -u -p -r1.159 -r1.161 --- mandoc/read.c 2017/02/03 17:56:59 1.159 +++ mandoc/read.c 2017/02/18 17:29:28 1.161 @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.159 2017/02/03 17:56:59 schwarze Exp $ */ +/* $Id: read.c,v 1.161 2017/02/18 17:29:28 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2017 Ingo Schwarze @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -48,8 +47,8 @@ #define REPARSE_LIMIT 1000 struct mparse { - struct roff_man *man; /* man parser */ struct roff *roff; /* roff parser (!NULL) */ + struct roff_man *man; /* man parser */ char *sodest; /* filename pointed to by .so */ const char *file; /* filename of current input file */ struct buf *primary; /* buffer currently being parsed */ @@ -603,12 +602,11 @@ static int read_whole_file(struct mparse *curp, const char *file, int fd, struct buf *fb, int *with_mmap) { + struct stat st; gzFile gz; size_t off; ssize_t ssz; - struct stat st; - if (fstat(fd, &st) == -1) err((int)MANDOCLEVEL_SYSERR, "%s", file); @@ -830,13 +828,14 @@ mparse_reset(struct mparse *curp) { roff_reset(curp->roff); roff_man_reset(curp->man); + + free(curp->sodest); + curp->sodest = NULL; + if (curp->secondary) curp->secondary->sz = 0; curp->file_status = MANDOCLEVEL_OK; - - free(curp->sodest); - curp->sodest = NULL; curp->gzip = 0; } @@ -845,8 +844,7 @@ mparse_free(struct mparse *curp) { roff_man_free(curp->man); - if (curp->roff) - roff_free(curp->roff); + roff_free(curp->roff); if (curp->secondary) free(curp->secondary->buf);