mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
fix(install): prevent use-after-free when retrying failed HTTP requests (#25949)
This commit is contained in:
@@ -431,6 +431,12 @@ fn drainEvents(this: *@This()) void {
|
||||
.async_http = http.*,
|
||||
});
|
||||
cloned.async_http.real = http;
|
||||
// Clear stale queue pointers - the clone inherited http.next and http.task.node.next
|
||||
// which may point to other AsyncHTTP structs that could be freed before the callback
|
||||
// copies data back to the original. If not cleared, retrying a failed request would
|
||||
// re-queue with stale pointers causing use-after-free.
|
||||
cloned.async_http.next = null;
|
||||
cloned.async_http.task.node.next = null;
|
||||
cloned.async_http.onStart();
|
||||
if (comptime Environment.allow_assert) {
|
||||
count += 1;
|
||||
|
||||
Reference in New Issue
Block a user