mirror of
https://github.com/curl/curl.git
synced 2026-08-25 14:23:39 +03:00
cfilter: unlink and discard
Rewrite the code that removes a filter from the connection and discards it. Always look at the connection, otherwise it will not work of the filter is at the top of the chain. Change QUIC filter setup code to always tear down the chain in construction when an error occured. HTTP proxy, do not remove the h1/h2 sub filter on close. Leave it to be discarded with the connection. Avoids keeping an additional pointer that might become dangling. Triggered by a reported on a code bug in discard method. Reported-by: Joshua Rogers Closes #18596
This commit is contained in:
parent
ca034e839c
commit
0f08211330
7 changed files with 54 additions and 85 deletions
|
|
@ -383,29 +383,26 @@ void Curl_conn_cf_insert_after(struct Curl_cfilter *cf_at,
|
|||
*pnext = tail;
|
||||
}
|
||||
|
||||
bool Curl_conn_cf_discard_sub(struct Curl_cfilter *cf,
|
||||
struct Curl_cfilter *discard,
|
||||
struct Curl_easy *data,
|
||||
bool destroy_always)
|
||||
bool Curl_conn_cf_discard(struct Curl_cfilter **pcf,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
struct Curl_cfilter **pprev = &cf->next;
|
||||
struct Curl_cfilter *cf = pcf ? *pcf : NULL;
|
||||
bool found = FALSE;
|
||||
|
||||
/* remove from sub-chain and destroy */
|
||||
DEBUGASSERT(cf);
|
||||
while(*pprev) {
|
||||
if(*pprev == cf) {
|
||||
*pprev = discard->next;
|
||||
discard->next = NULL;
|
||||
found = TRUE;
|
||||
break;
|
||||
if(cf) {
|
||||
if(cf->conn) {
|
||||
/* unlink if present in connection filter chain */
|
||||
struct Curl_cfilter **pprev = &cf->conn->cfilter[cf->sockindex];
|
||||
while(*pprev) {
|
||||
if(*pprev == *pcf) {
|
||||
*pprev = (*pcf)->next;
|
||||
cf->next = NULL;
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
pprev = &((*pprev)->next);
|
||||
}
|
||||
}
|
||||
pprev = &((*pprev)->next);
|
||||
}
|
||||
if(found || destroy_always) {
|
||||
discard->next = NULL;
|
||||
discard->cft->destroy(discard, data);
|
||||
free(discard);
|
||||
Curl_conn_cf_discard_chain(pcf, data);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue