From e16022362777dc62fd77e95c0db0807c3be4ea2c Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 20 Sep 2023 23:40:42 -0700 Subject: [PATCH] In http client, use .toOwnedSlice() instead of potentially re-using the WTFString here --- src/http_client_async.zig | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/http_client_async.zig b/src/http_client_async.zig index 3cc0440038..1b03483a00 100644 --- a/src/http_client_async.zig +++ b/src/http_client_async.zig @@ -3488,11 +3488,14 @@ pub fn handleResponseMetadata( ); defer new_url_.deref(); - if (new_url_.utf8ByteLength() > url_buf.data.len) { - return error.RedirectURLTooLong; + if (new_url_.isEmpty()) { + return error.InvalidRedirectURL; } - const new_url = new_url_.toUTF8(fba.allocator()); - this.url = URL.parse(new_url.slice()); + + const new_url = new_url_.toOwnedSlice(fba.allocator()) catch { + return error.RedirectURLTooLong; + }; + this.url = URL.parse(new_url); is_same_origin = strings.eqlCaseInsensitiveASCII(strings.withoutTrailingSlash(this.url.origin), strings.withoutTrailingSlash(original_url.origin), true); deferred_redirect.* = this.redirect;