summaryrefslogtreecommitdiffstats
path: root/ssl/packet.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2018-04-03 11:31:16 -0400
committerRich Salz <rsalz@openssl.org>2018-04-03 11:31:16 -0400
commitcdb10bae3f773401e039c55965eb177a6f3fc160 (patch)
treec69b1b2bc385d3f600684cf8285b9ff80322c48f /ssl/packet.c
parent29f484d00d732ea4c19a7fd3dc0440045653e79e (diff)
Set error code on alloc failures
Almost all *alloc failures now set an error code. Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/5842)
Diffstat (limited to 'ssl/packet.c')
-rw-r--r--ssl/packet.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/ssl/packet.c b/ssl/packet.c
index 7a4414ae6a..18198009cc 100644
--- a/ssl/packet.c
+++ b/ssl/packet.c
@@ -9,6 +9,7 @@
#include "internal/cryptlib.h"
#include "packet_locl.h"
+#include <openssl/sslerr.h>
#define DEFAULT_BUF_SIZE 256
@@ -93,9 +94,10 @@ static int wpacket_intern_init_len(WPACKET *pkt, size_t lenbytes)
pkt->curr = 0;
pkt->written = 0;
- pkt->subs = OPENSSL_zalloc(sizeof(*pkt->subs));
- if (pkt->subs == NULL)
+ if ((pkt->subs = OPENSSL_zalloc(sizeof(*pkt->subs))) == NULL) {
+ SSLerr(SSL_F_WPACKET_INTERN_INIT_LEN, ERR_R_MALLOC_FAILURE);
return 0;
+ }
if (lenbytes == 0)
return 1;
@@ -276,9 +278,10 @@ int WPACKET_start_sub_packet_len__(WPACKET *pkt, size_t lenbytes)
if (!ossl_assert(pkt->subs != NULL))
return 0;
- sub = OPENSSL_zalloc(sizeof(*sub));
- if (sub == NULL)
+ if ((sub = OPENSSL_zalloc(sizeof(*sub))) == NULL) {
+ SSLerr(SSL_F_WPACKET_START_SUB_PACKET_LEN__, ERR_R_MALLOC_FAILURE);
return 0;
+ }
sub->parent = pkt->subs;
pkt->subs = sub;