Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transp: deref qent only if qentp is not set #1061

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions src/sip/transp.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,14 @@ static void conn_close(struct sip_conn *conn, int err)

struct sip_connqent *qent = le->data;
le = le->next;

if (qent->qentp) {
*qent->qentp = NULL;
qent->qentp = NULL;
}
bool qentp_set = qent->qentp ? true : false;

qent->transph(err, qent->arg);
list_unlink(&qent->le);
mem_deref(qent);

if (!qentp_set) {
list_unlink(&qent->le);
mem_deref(qent);
}
}

sip_keepalive_signal(&conn->kal, err);
Expand Down Expand Up @@ -618,13 +617,9 @@ static void tcp_estab_handler(void *arg)
while (le) {

struct sip_connqent *qent = le->data;
bool qentp_set = qent->qentp ? true : false;
le = le->next;

if (qent->qentp) {
*qent->qentp = NULL;
qent->qentp = NULL;
}

trace_send(conn->sip,
conn->sc ? SIP_TRANSP_TLS : SIP_TRANSP_TCP,
conn,
Expand All @@ -634,8 +629,10 @@ static void tcp_estab_handler(void *arg)
if (err)
qent->transph(err, qent->arg);

list_unlink(&qent->le);
mem_deref(qent);
if (!qentp_set) {
list_unlink(&qent->le);
mem_deref(qent);
}
}
}

Expand Down Expand Up @@ -896,13 +893,9 @@ static void websock_estab_handler(void *arg)
while (le) {

struct sip_connqent *qent = le->data;
bool qentp_set = qent->qentp ? true : false;
le = le->next;

if (qent->qentp) {
*qent->qentp = NULL;
qent->qentp = NULL;
}

trace_send(conn->sip,
conn->tp,
conn,
Expand All @@ -917,8 +910,10 @@ static void websock_estab_handler(void *arg)
if (err)
qent->transph(err, qent->arg);

list_unlink(&qent->le);
mem_deref(qent);
if (!qentp_set) {
list_unlink(&qent->le);
mem_deref(qent);
}
}
}

Expand Down
Loading