diff options
author | 2023-09-20 23:40:42 -0700 | |
---|---|---|
committer | 2023-09-20 23:40:42 -0700 | |
commit | e16022362777dc62fd77e95c0db0807c3be4ea2c (patch) | |
tree | 76c156d811f1f9f476aa3b2849c3731ce5952b2c | |
parent | b00588e98cc4ab5254dca1c6e69829de6e1fd993 (diff) | |
download | bun-e16022362777dc62fd77e95c0db0807c3be4ea2c.tar.gz bun-e16022362777dc62fd77e95c0db0807c3be4ea2c.tar.zst bun-e16022362777dc62fd77e95c0db0807c3be4ea2c.zip |
In http client, use .toOwnedSlice() instead of potentially re-using the WTFString here
-rw-r--r-- | src/http_client_async.zig | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/http_client_async.zig b/src/http_client_async.zig index 3cc044003..1b03483a0 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; |