summaryrefslogtreecommitdiff
path: root/lib/libssl
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2023-07-02 20:16:48 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2023-07-02 20:16:48 +0000
commite9d425bbe4989fcae33ff7295ab4b97a57d39723 (patch)
treeacfd8922dd8da1f37f6bbd24b6f8921954e45a22 /lib/libssl
parentfbfa3c99d8e209b7d321f7c0d9fffd39b1d5b7c7 (diff)
Simplify allocation checks
Instead of attempting to allocate a few times and only then check all the returned pointers for NULL, allocate and check one after the othre. This is easier on the eyes and what we usually do. Prompted by a report by Ilya Shipitsin ok beck
Diffstat (limited to 'lib/libssl')
-rw-r--r--lib/libssl/d1_pkt.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/libssl/d1_pkt.c b/lib/libssl/d1_pkt.c
index 5409d3923bb..df9581a3cef 100644
--- a/lib/libssl/d1_pkt.c
+++ b/lib/libssl/d1_pkt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: d1_pkt.c,v 1.127 2022/11/26 16:08:55 tb Exp $ */
+/* $OpenBSD: d1_pkt.c,v 1.128 2023/07/02 20:16:47 tb Exp $ */
/*
* DTLS implementation written by Nagendra Modadugu
* (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
@@ -206,16 +206,16 @@ dtls1_copy_record(SSL *s, DTLS1_RECORD_DATA_INTERNAL *rdata)
static int
dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority)
{
- DTLS1_RECORD_DATA_INTERNAL *rdata;
- pitem *item;
+ DTLS1_RECORD_DATA_INTERNAL *rdata = NULL;
+ pitem *item = NULL;
/* Limit the size of the queue to prevent DOS attacks */
if (pqueue_size(queue->q) >= 100)
return 0;
- rdata = malloc(sizeof(DTLS1_RECORD_DATA_INTERNAL));
- item = pitem_new(priority, rdata);
- if (rdata == NULL || item == NULL)
+ if ((rdata = malloc(sizeof(*rdata))) == NULL)
+ goto init_err;
+ if ((item = pitem_new(priority, rdata)) == NULL)
goto init_err;
rdata->packet = s->packet;
@@ -252,16 +252,16 @@ dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority)
static int
dtls1_buffer_rcontent(SSL *s, rcontent_pqueue *queue, unsigned char *priority)
{
- DTLS1_RCONTENT_DATA_INTERNAL *rdata;
- pitem *item;
+ DTLS1_RCONTENT_DATA_INTERNAL *rdata = NULL;
+ pitem *item = NULL;
/* Limit the size of the queue to prevent DOS attacks */
if (pqueue_size(queue->q) >= 100)
return 0;
- rdata = malloc(sizeof(DTLS1_RCONTENT_DATA_INTERNAL));
- item = pitem_new(priority, rdata);
- if (rdata == NULL || item == NULL)
+ if ((rdata = malloc(sizeof(*rdata))) == NULL)
+ goto init_err;
+ if ((item = pitem_new(priority, rdata)) == NULL)
goto init_err;
rdata->rcontent = s->s3->rcontent;