From dbb0321014c9746e44d4338a27ddf946d757f262 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Thu, 24 Sep 2015 13:49:03 -0400 Subject: Clarify that only top-level CBBs get CBB_cleanup. Also add an assert to that effect. Change-Id: I1bd0571e3889f1cba968fd99041121ac42ee9e89 Reviewed-on: https://boringssl-review.googlesource.com/5990 Reviewed-by: Adam Langley --- crypto/bytestring/cbb.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crypto') diff --git a/crypto/bytestring/cbb.c b/crypto/bytestring/cbb.c index 1da6a21e..5d7485a8 100644 --- a/crypto/bytestring/cbb.c +++ b/crypto/bytestring/cbb.c @@ -70,6 +70,10 @@ int CBB_init_fixed(CBB *cbb, uint8_t *buf, size_t len) { void CBB_cleanup(CBB *cbb) { if (cbb->base) { + /* Only top-level |CBB|s are cleaned up. Child |CBB|s are non-owning. They + * are implicitly discarded when the parent is flushed or cleaned up. */ + assert(cbb->is_top_level); + if (cbb->base->can_resize) { OPENSSL_free(cbb->base->buf); } -- cgit v1.2.3