Unchecked malloc fixes
[openssl.git] / ssl / s3_pkt.c
index d5ddb609d2bca7fa5ab3e45ff6354960fc3bdaf2..136d273d062efec777b84d8469b27aad8b082cfd 100644 (file)
@@ -708,6 +708,10 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
                 packlen *= 4;
 
             wb->buf = OPENSSL_malloc(packlen);
+            if(!wb->buf) {
+                SSLerr(SSL_F_SSL3_WRITE_BYTES, ERR_R_MALLOC_FAILURE);
+                return -1;
+            }
             wb->len = packlen;
         } else if (tot == len) { /* done? */
             OPENSSL_free(wb->buf); /* free jumbo buffer */