]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mail_storage_set_critical() - don't free old error_string too early
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 25 Aug 2017 15:02:44 +0000 (18:02 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Sun, 27 Aug 2017 12:19:26 +0000 (15:19 +0300)
It may be used in one of the parameters.

src/lib-storage/mail-storage.c

index 1792f5962b6b90566a6a1484014ac382f3ac67c3..136b4cb160a1722e2c4d097b4e5c841daaaf5a84 100644 (file)
@@ -542,9 +542,11 @@ void mail_storage_set_internal_error(struct mail_storage *storage)
 void mail_storage_set_critical(struct mail_storage *storage,
                               const char *fmt, ...)
 {
-       char *old_error = storage->last_internal_error;
+       char *old_error = storage->error_string;
+       char *old_internal_error = storage->last_internal_error;
        va_list va;
 
+       storage->error_string = NULL;
        storage->last_internal_error = NULL;
        /* critical errors may contain sensitive data, so let user
           see only "Internal error" with a timestamp to make it
@@ -557,9 +559,10 @@ void mail_storage_set_critical(struct mail_storage *storage,
        storage->last_error_is_internal = TRUE;
        i_error("%s", storage->last_internal_error);
 
-       /* free the old_error only after the new error is generated, because
-          the old_error may be one of the parameters. */
+       /* free the old_error and old_internal_error only after the new error
+          is generated, because they may be one of the parameters. */
        i_free(old_error);
+       i_free(old_internal_error);
 }
 
 const char *mail_storage_get_last_internal_error(struct mail_storage *storage,