From 28fd0ab40739e8cb73f208e30f78d8aa7a0a6d19 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Wed, 15 Jun 2016 11:44:35 +0200 Subject: estream: Fix assertion failure due to es_flush. * src/estream.c (es_writen): Set writing flag even if no data was written. -- GnuPG-bug-id: 2371 Signed-off-by: Werner Koch gniibe tracked the problem down to a fully valid change in GnuPG (gnupg commit 12af2630cf4d1a39179179925fac8f2cce7504ff). He wrote: This is the first instance for estream to do READ and WRITE (in the history of the code > 10 years :-). In the [gnupg] function agent_write_private_key, the pattern is: es_fopen es_fread es_fseek es_fwrite which should work well, but if results core dump by assertion failure in the function es_flush of libgpg-error. --- src/estream.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/estream.c b/src/estream.c index 2033b23..e382a29 100644 --- a/src/estream.c +++ b/src/estream.c @@ -2679,6 +2679,7 @@ es_writen (estream_t _GPGRT__RESTRICT stream, else goto out; } + stream->flags.writing = 1; } } @@ -2701,9 +2702,6 @@ es_writen (estream_t _GPGRT__RESTRICT stream, if (bytes_written) *bytes_written = data_written; - if (data_written) - if (!stream->flags.writing) - stream->flags.writing = 1; return err; } -- cgit v1.2.3