Skip to content

Commit 00433ba

Browse files
authored
net.urllib: avoid a double free in set_path() when compiled with -autofree (#11427)
1 parent 79c2bca commit 00433ba

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

vlib/net/urllib/urllib.v

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -622,15 +622,8 @@ fn parse_host(host string) ?string {
622622
// set_path will return an error only if the provided path contains an invalid
623623
// escaping.
624624
pub fn (mut u URL) set_path(p string) ?bool {
625-
path := unescape(p, .encode_path) ?
626-
u.path = path
627-
escp := escape(path, .encode_path)
628-
if p == escp {
629-
// Default encoding is fine.
630-
u.raw_path = ''
631-
} else {
632-
u.raw_path = p
633-
}
625+
u.path = unescape(p, .encode_path) ?
626+
u.raw_path = if p == escape(u.path, .encode_path) { '' } else { p }
634627
return true
635628
}
636629

0 commit comments

Comments
 (0)