From: Olivier Houchard Date: Tue, 24 Oct 2017 15:42:47 +0000 (+0200) Subject: BUG/MEDIUM: server: Allocate tmptrash before using it. X-Git-Tag: v1.8-rc1~243 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=796a2b3324907e0349c8dd071208dd621a528725;p=thirdparty%2Fhaproxy.git 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] --- diff --git a/src/server.c b/src/server.c index f57434a293..844d6963bd 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 */