From 00433ba460ca666b3a5587ef45fe97956210c879 Mon Sep 17 00:00:00 2001 From: Dialga Date: Wed, 8 Sep 2021 06:11:03 +1200 Subject: [PATCH] net.urllib: avoid a double free in set_path() when compiled with -autofree (#11427) --- vlib/net/urllib/urllib.v | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/vlib/net/urllib/urllib.v b/vlib/net/urllib/urllib.v index 30480f4357..75f0ffa9dd 100644 --- a/vlib/net/urllib/urllib.v +++ b/vlib/net/urllib/urllib.v @@ -622,15 +622,8 @@ fn parse_host(host string) ?string { // set_path will return an error only if the provided path contains an invalid // escaping. pub fn (mut u URL) set_path(p string) ?bool { - path := unescape(p, .encode_path) ? - u.path = path - escp := escape(path, .encode_path) - if p == escp { - // Default encoding is fine. - u.raw_path = '' - } else { - u.raw_path = p - } + u.path = unescape(p, .encode_path) ? + u.raw_path = if p == escape(u.path, .encode_path) { '' } else { p } return true }