Skip to content

Commit

Permalink
Ensure DTLS free functions can handle NULL
Browse files Browse the repository at this point in the history
Our free functions should be able to deal with the case where the object
being freed is NULL. This turns out to not be quite the case for DTLS
related objects.

Fixes #13649

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #13655)

(cherry picked from commit d0afb30)
  • Loading branch information
mattcaswell committed Jan 8, 2021
1 parent a953f26 commit 37d9e3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ssl/d1_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ void dtls1_free(SSL *s)

ssl3_free(s);

dtls1_clear_queues(s);

pqueue_free(s->d1->buffered_messages);
pqueue_free(s->d1->sent_messages);
if (s->d1 != NULL) {
dtls1_clear_queues(s);
pqueue_free(s->d1->buffered_messages);
pqueue_free(s->d1->sent_messages);
}

OPENSSL_free(s->d1);
s->d1 = NULL;
Expand Down
3 changes: 3 additions & 0 deletions ssl/record/rec_layer_d1.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ int DTLS_RECORD_LAYER_new(RECORD_LAYER *rl)

void DTLS_RECORD_LAYER_free(RECORD_LAYER *rl)
{
if (rl->d == NULL)
return;

DTLS_RECORD_LAYER_clear(rl);
pqueue_free(rl->d->unprocessed_rcds.q);
pqueue_free(rl->d->processed_rcds.q);
Expand Down

0 comments on commit 37d9e3d

Please sign in to comment.