From 796a2b3324907e0349c8dd071208dd621a528725 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Tue, 24 Oct 2017 17:42:47 +0200 Subject: [PATCH] BUG/MEDIUM: server: Allocate tmptrash before using it. Don't forget to allocate tmptrash before using it, and free it once we're done. [wt: introduced by commit 64cc49cf ("MAJOR: servers: propagate server status changes asynchronously"), no backport needed] --- src/server.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/server.c b/src/server.c index f57434a29..844d6963b 100644 --- a/src/server.c +++ b/src/server.c @@ -4655,16 +4655,21 @@ void srv_update_status(struct server *s) } if (s->cur_state == SRV_ST_STOPPED) { /* server was already down */ - chunk_printf(tmptrash, - "%sServer %s/%s was DOWN and now enters maintenance%s%s%s", - s->flags & SRV_F_BACKUP ? "Backup " : "", s->proxy->id, s->id, - *(s->adm_st_chg_cause) ? " (" : "", s->adm_st_chg_cause, *(s->adm_st_chg_cause) ? ")" : ""); + tmptrash = alloc_trash_chunk(); + if (tmptrash) { + chunk_printf(tmptrash, + "%sServer %s/%s was DOWN and now enters maintenance%s%s%s", + s->flags & SRV_F_BACKUP ? "Backup " : "", s->proxy->id, s->id, + *(s->adm_st_chg_cause) ? " (" : "", s->adm_st_chg_cause, *(s->adm_st_chg_cause) ? ")" : ""); - srv_append_status(tmptrash, s, NULL, -1, (s->next_admin & SRV_ADMF_FMAINT)); + srv_append_status(tmptrash, s, NULL, -1, (s->next_admin & SRV_ADMF_FMAINT)); - if (!(global.mode & MODE_STARTING)) { - Warning("%s.\n", tmptrash->str); - send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str); + if (!(global.mode & MODE_STARTING)) { + Warning("%s.\n", tmptrash->str); + send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str); + } + free_trash_chunk(tmptrash); + tmptrash = NULL; } } else { /* server was still running */