Fix TLS certificate allocation (#259)

* Fix TLS certificate allocation

* change style + comment
This commit is contained in:
Tanguy 2022-01-28 12:46:15 +01:00 committed by GitHub
parent b47b2a96ce
commit 8719723077
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -708,7 +708,8 @@ proc init*(tt: typedesc[TLSCertificate],
##
## This procedure initializes array of certificates from PEM encoded string.
var items = pemDecode(data)
var res = TLSCertificate()
# storage needs to be big enough for input data
var res = TLSCertificate(storage: newSeqOfCap[byte](data.len))
for item in items:
if item.name == "CERTIFICATE" and len(item.data) > 0:
let offset = len(res.storage)