base64: better alloc size

The previous algorithm allocated more bytes than necessary.

Suggested-by: xtonik on github
Fixes #10024
Closes #10025
This commit is contained in:
Daniel Stenberg 2022-12-04 00:07:52 +01:00
parent 29bb9ba431
commit fa467a2fa9
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -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;