From: Daniel Stenberg Date: Sat, 3 Dec 2022 23:07:52 +0000 (+0100) Subject: base64: better alloc size X-Git-Tag: curl-7_87_0~71 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fa467a2fa98f6420db55c3b359fb0beed574bbbf;p=thirdparty%2Fcurl.git base64: better alloc size The previous algorithm allocated more bytes than necessary. Suggested-by: xtonik on github Fixes #10024 Closes #10025 --- diff --git a/lib/base64.c b/lib/base64.c index 52654c2bc3..2760e7bbe8 100644 --- a/lib/base64.c +++ b/lib/base64.c @@ -192,7 +192,7 @@ static CURLcode base64_encode(const char *table64, return CURLE_OUT_OF_MEMORY; #endif - base64data = output = malloc(insize * 4 / 3 + 4); + base64data = output = malloc((insize + 2) / 3 * 4 + 1); if(!output) return CURLE_OUT_OF_MEMORY;