aboutsummaryrefslogtreecommitdiffstats
path: root/common/iobuf.c
diff options
context:
space:
mode:
authorNeal H. Walfield <[email protected]>2015-08-13 08:08:32 +0000
committerNeal H. Walfield <[email protected]>2015-08-20 12:16:21 +0000
commit1f94646a86348128f585301fcd605e5e703fd77d (patch)
tree19459acea2939ae39834f2f8c1c01a3b405fa7f4 /common/iobuf.c
parentcommon/iobuf.c: Improve iobuf_peek. (diff)
downloadgnupg-1f94646a86348128f585301fcd605e5e703fd77d.tar.gz
gnupg-1f94646a86348128f585301fcd605e5e703fd77d.zip
common/iobuf.c: Don't abort freeing a pipeline if freeing a filter fails
* common/iobuf.c (iobuf_cancel): Don't abort freeing a pipeline if freeing a filter fails. This needs to a memory leak. Instead, keep freeing and return the error code of the first filter that fails. -- Signed-off-by: Neal H. Walfield <[email protected]>.
Diffstat (limited to '')
-rw-r--r--common/iobuf.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/common/iobuf.c b/common/iobuf.c
index 4f098859d..203f10a6c 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -1133,13 +1133,16 @@ iobuf_alloc (int use, size_t bufsize)
int
iobuf_close (iobuf_t a)
{
- iobuf_t a2;
+ iobuf_t a_chain;
size_t dummy_len = 0;
int rc = 0;
- for (; a && !rc; a = a2)
+ for (; a; a = a_chain)
{
- a2 = a->chain;
+ int rc2 = 0;
+
+ a_chain = a->chain;
+
if (a->use == IOBUF_OUTPUT && (rc = iobuf_flush (a)))
log_error ("iobuf_flush failed on close: %s\n", gpg_strerror (rc));
@@ -1147,9 +1150,14 @@ iobuf_close (iobuf_t a)
log_debug ("iobuf-%d.%d: close '%s'\n",
a->no, a->subno, iobuf_desc (a));
- if (a->filter && (rc = a->filter (a->filter_ov, IOBUFCTRL_FREE,
- a->chain, NULL, &dummy_len)))
+ if (a->filter && (rc2 = a->filter (a->filter_ov, IOBUFCTRL_FREE,
+ a->chain, NULL, &dummy_len)))
log_error ("IOBUFCTRL_FREE failed on close: %s\n", gpg_strerror (rc));
+ if (! rc && rc2)
+ /* Whoops! An error occured. Save it in RC if we haven't
+ already recorded an error. */
+ rc = rc2;
+
xfree (a->real_fname);
if (a->d.buf)
{