diff options
author | David Benjamin <davidben@chromium.org> | 2015-09-24 20:49:03 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2015-09-29 01:40:01 +0300 |
commit | dbb0321014c9746e44d4338a27ddf946d757f262 (patch) | |
tree | e5e5e64b2781565a0c4f313baaa9730a7ed778aa /crypto/bytestring/cbb.c | |
parent | df6a3f8b959fcf9233abd83f7605b323a48f0c9c (diff) |
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 <agl@google.com>
Diffstat (limited to 'crypto/bytestring/cbb.c')
-rw-r--r-- | crypto/bytestring/cbb.c | 4 |
1 files changed, 4 insertions, 0 deletions
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); } |