From fa467a2fa98f6420db55c3b359fb0beed574bbbf Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 4 Dec 2022 00:07:52 +0100 Subject: [PATCH] base64: better alloc size The previous algorithm allocated more bytes than necessary. Suggested-by: xtonik on github Fixes #10024 Closes #10025 --- lib/base64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.47.3