From 7d3476cbca57ae1bcae794f4c93e44191643dc8c Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 7 Aug 2021 14:37:51 +0300 Subject: [PATCH] ci: fix tests-sanitize-address-clang job (regression after 9995f6c) --- vlib/encoding/base64/base64.v | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vlib/encoding/base64/base64.v b/vlib/encoding/base64/base64.v index 61ffd4f583..ad0672257a 100644 --- a/vlib/encoding/base64/base64.v +++ b/vlib/encoding/base64/base64.v @@ -31,12 +31,13 @@ mut: // Please note: If you need to decode many strings repeatedly, take a look at `decode_in_buffer`. // Example: assert base64.decode('ViBpbiBiYXNlIDY0') == 'V in base 64' pub fn decode(data string) []byte { - size := data.len * 3 / 4 + mut size := i64(data.len) * 3 / 4 if size <= 0 || data.len % 4 != 0 { return [] } + size = (size + 3) & ~0x03 // round to the next multiple of 4 (the decoding loop writes multiples of 4 bytes) unsafe { - buffer := malloc(size) + buffer := malloc(int(size)) n := decode_in_buffer(data, buffer) return buffer.vbytes(n) } @@ -215,7 +216,6 @@ fn decode_from_buffer(dest &byte, src &byte, src_len int) int { for src_len - si >= 4 { datablock_32.data = assemble32(byte(base64.index[d[si + 0]]), byte(base64.index[d[si + 1]]), byte(base64.index[d[si + 2]]), byte(base64.index[d[si + 3]])) - $if little_endian { b[n_decoded_bytes + 0] = datablock_32.data_byte[3] b[n_decoded_bytes + 1] = datablock_32.data_byte[2]