Module Name: src
Committed By: christos
Date: Thu Jan 7 19:49:25 UTC 2016
Modified Files:
src/external/bsd/mdocml/dist: read.c
Log Message:
CID 1288947: Prevent fd leak.
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/mdocml/dist/read.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/mdocml/dist/read.c
diff -u src/external/bsd/mdocml/dist/read.c:1.12 src/external/bsd/mdocml/dist/read.c:1.13
--- src/external/bsd/mdocml/dist/read.c:1.12 Fri Dec 18 09:30:41 2015
+++ src/external/bsd/mdocml/dist/read.c Thu Jan 7 14:49:25 2016
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.12 2015/12/18 14:30:41 christos Exp $ */
+/* $Id: read.c,v 1.13 2016/01/07 19:49:25 christos Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <[email protected]>
* Copyright (c) 2010-2015 Ingo Schwarze <[email protected]>
@@ -336,6 +336,7 @@ mparse_buf_r(struct mparse *curp, const
lnn = curp->line;
pos = 0;
+ fd = -1;
while (i < blk.sz) {
if (0 == pos && '\0' == blk.buf[i])
@@ -530,8 +531,7 @@ rerun:
if ( ! (curp->options & MPARSE_SO) &&
(i >= blk.sz || blk.buf[i] == '\0')) {
curp->sodest = mandoc_strdup(ln.buf + of);
- free(ln.buf);
- return;
+ goto out;
}
/*
* We remove `so' clauses from our lookaside
@@ -611,7 +611,10 @@ rerun:
pos = 0;
}
+out:
free(ln.buf);
+ if (fd != -1)
+ close(fd);
}
static int