mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-13 05:51:42 +00:00
XHTTP client: Fix potential memory leak in stream-up/one (#6095)
Fixes https://github.com/XTLS/Xray-core/pull/6087#issuecomment-4402474552
This commit is contained in:
parent
eb32d166af
commit
9d9eaf399f
1 changed files with 2 additions and 0 deletions
|
|
@ -71,6 +71,7 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, sessio
|
|||
errors.LogInfoInner(ctx, err, "failed to "+method+" "+url)
|
||||
}
|
||||
gotConn.Close()
|
||||
common.Close(body)
|
||||
wrc.Close()
|
||||
return
|
||||
}
|
||||
|
|
@ -80,6 +81,7 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, sessio
|
|||
if resp.StatusCode != 200 || uploadOnly { // stream-up
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
resp.Body.Close() // if it is called immediately, the upload will be interrupted also
|
||||
common.Close(body)
|
||||
wrc.Close()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue