summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libssl/bs_cbb.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/libssl/bs_cbb.c b/src/lib/libssl/bs_cbb.c
index 154a7964e6..dd1dc73d09 100644
--- a/src/lib/libssl/bs_cbb.c
+++ b/src/lib/libssl/bs_cbb.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bs_cbb.c,v 1.15 2017/04/14 15:20:55 jsing Exp $ */ 1/* $OpenBSD: bs_cbb.c,v 1.16 2017/05/07 05:03:41 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014, Google Inc. 3 * Copyright (c) 2014, Google Inc.
4 * 4 *
@@ -22,6 +22,8 @@
22 22
23#include "bytestring.h" 23#include "bytestring.h"
24 24
25#define CBB_INITIAL_SIZE 64
26
25static int 27static int
26cbb_init(CBB *cbb, uint8_t *buf, size_t cap) 28cbb_init(CBB *cbb, uint8_t *buf, size_t cap)
27{ 29{
@@ -49,10 +51,11 @@ CBB_init(CBB *cbb, size_t initial_capacity)
49 51
50 memset(cbb, 0, sizeof(*cbb)); 52 memset(cbb, 0, sizeof(*cbb));
51 53
52 if (initial_capacity > 0) { 54 if (initial_capacity == 0)
53 if ((buf = malloc(initial_capacity)) == NULL) 55 initial_capacity = CBB_INITIAL_SIZE;
54 return 0; 56
55 } 57 if ((buf = malloc(initial_capacity)) == NULL)
58 return 0;
56 59
57 if (!cbb_init(cbb, buf, initial_capacity)) { 60 if (!cbb_init(cbb, buf, initial_capacity)) {
58 free(buf); 61 free(buf);