From: Jérémie Astor Date: Tue, 3 Mar 2020 15:47:18 +0000 (+0100) Subject: :bomb: Fix vasprintf leak X-Git-Tag: nightly~1726^2~52 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=a72fe2cb1237b8f698f0708b82afa2675b7f738b;p=gwion.git :bomb: Fix vasprintf leak --- 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;