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.2.34~283 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=38d282f9f8b7443a613990ccf4f456e2d02acb45;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 321c4cf0c6..9cd1242765 100644 --- a/src/lib/iostream.c +++ b/src/lib/iostream.c @@ -105,8 +105,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,