From: Timo Sirainen Date: Mon, 9 Oct 2017 15:31:52 +0000 (+0300) Subject: lib: io_stream_set_error() - Allow one of the parameters to be the old error X-Git-Tag: 2.3.0.rc1~846 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f0910b5cd80f62d9c5862aedbf62ee90374b2bca;p=thirdparty%2Fdovecot%2Fcore.git lib: io_stream_set_error() - Allow one of the parameters to be the old error --- diff --git a/src/lib/iostream.c b/src/lib/iostream.c index cb7d9fa6e1..7d1762c491 100644 --- a/src/lib/iostream.c +++ b/src/lib/iostream.c @@ -110,8 +110,11 @@ void io_stream_set_error(struct iostream_private *stream, void io_stream_set_verror(struct iostream_private *stream, const char *fmt, va_list args) { + /* one of the parameters may be the old stream->error, so don't free + it before the new error is created. */ + char *error = i_strdup_vprintf(fmt, args); i_free(stream->error); - stream->error = i_strdup_vprintf(fmt, args); + stream->error = error; } const char *io_stream_get_disconnect_reason(struct istream *input,