ci: fix tests-sanitize-address-clang job (regression after 9995f6c)

pull/11094/head
Delyan Angelov 2021-08-07 14:37:51 +03:00
parent 9995f6cca1
commit 7d3476cbca
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 3 additions and 3 deletions

View File

@ -31,12 +31,13 @@ mut:
// Please note: If you need to decode many strings repeatedly, take a look at `decode_in_buffer`. // 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' // Example: assert base64.decode('ViBpbiBiYXNlIDY0') == 'V in base 64'
pub fn decode(data string) []byte { 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 { if size <= 0 || data.len % 4 != 0 {
return [] return []
} }
size = (size + 3) & ~0x03 // round to the next multiple of 4 (the decoding loop writes multiples of 4 bytes)
unsafe { unsafe {
buffer := malloc(size) buffer := malloc(int(size))
n := decode_in_buffer(data, buffer) n := decode_in_buffer(data, buffer)
return buffer.vbytes(n) 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 { for src_len - si >= 4 {
datablock_32.data = assemble32(byte(base64.index[d[si + 0]]), byte(base64.index[d[si + 1]]), 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]])) byte(base64.index[d[si + 2]]), byte(base64.index[d[si + 3]]))
$if little_endian { $if little_endian {
b[n_decoded_bytes + 0] = datablock_32.data_byte[3] b[n_decoded_bytes + 0] = datablock_32.data_byte[3]
b[n_decoded_bytes + 1] = datablock_32.data_byte[2] b[n_decoded_bytes + 1] = datablock_32.data_byte[2]