From a72fe2cb1237b8f698f0708b82afa2675b7f738b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Tue, 3 Mar 2020 16:47:18 +0100 Subject: [PATCH] :bomb: Fix vasprintf leak --- src/lib/gack.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/gack.c b/src/lib/gack.c index a72059ae..1f04a9f7 100644 --- a/src/lib/gack.c +++ b/src/lib/gack.c @@ -27,7 +27,11 @@ ANN2(2) static int gw_vasprintf(MemPool mp, char **str, const char *fmt, va_list char *ret = mp_malloc2(mp, base_len + size + 1); if(base) strcpy(ret, base); - DECL_BB(const int, final_len, = vsprintf(ret + base_len, fmt, args)) + const int final_len = vsprintf(ret + base_len, fmt, args); + if(final_len < 0) { + mp_free2(mp, base_len + size + 1, ret); + return -1; + } if(base) mp_free2(mp, strlen(base), base); *str = ret; -- 2.43.0