Fix invalid base64 produced by love.data.encode when the input data has byte values greater than 252. Resolves issue #1374.

This commit is contained in:
Alex Szpakowski
2018-02-07 22:28:33 -04:00
parent 2f17cab3b4
commit a361b5c330
+1 -1
View File
@@ -38,7 +38,7 @@ static const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$
**/
static void b64_encode_block(char in[3], char out[4], int len)
{
out[0] = (char) cb64[(int)(in[0] >> 2)];
out[0] = (char) cb64[(int)((in[0] & 0xfc) >> 2)];
out[1] = (char) cb64[(int)(((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4))];
out[2] = (char) (len > 1 ? cb64[(int)(((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6))] : '=');
out[3] = (char) (len > 2 ? cb64[(int)(in[2] & 0x3f)] : '=');