1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net.urllib: fix double free in escape() (#11390)

This commit is contained in:
Dialga 2021-09-04 23:57:09 +12:00 committed by GitHub
parent 923ef733c0
commit 9b983bdd95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -272,14 +272,8 @@ fn escape(s string, mode EncodingMode) string {
if space_count == 0 && hex_count == 0 {
return s
}
buf := []byte{len: (64)}
mut t := []byte{}
required := s.len + 2 * hex_count
if required <= buf.len {
t = buf[..required]
} else {
t = []byte{len: required}
}
mut t := []byte{len: required}
if hex_count == 0 {
copy(t, s.bytes())
for i in 0 .. s.len {