From 2732e2cfdbe1015bba929fdf4bc80521f3e32b16 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 18 Oct 2021 10:15:16 +0000 Subject: Fix error case in readbigpem Signed-off-by: Laurent Bercot --- src/sbearssl/sbearssl_cert_readbigpem.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/sbearssl/sbearssl_cert_readbigpem.c b/src/sbearssl/sbearssl_cert_readbigpem.c index 9e6339a..7c6fc5b 100644 --- a/src/sbearssl/sbearssl_cert_readbigpem.c +++ b/src/sbearssl/sbearssl_cert_readbigpem.c @@ -24,11 +24,12 @@ int sbearssl_cert_readbigpem (char const *fn, genalloc *certs, stralloc *sa) size_t i = 0 ; int certswasnull = !genalloc_s(sbearssl_cert, certs) ; int sawasnull = !sa->s ; - int r ; if (fd < 0) return -1 ; - r = sbearssl_pem_decode_from_buffer(&b, &pems, sa) ; - fd_close(fd) ; - if (r) return r ; + { + int r = sbearssl_pem_decode_from_buffer(&b, &pems, sa) ; + fd_close(fd) ; + if (r) return r ; + } p = genalloc_s(sbearssl_pemobject, &pems) ; n = genalloc_len(sbearssl_pemobject, &pems) ; for (; i < n ; i++) @@ -51,5 +52,5 @@ int sbearssl_cert_readbigpem (char const *fn, genalloc *certs, stralloc *sa) if (sawasnull) stralloc_free(sa) ; else sa->len = sabase ; genalloc_free(sbearssl_pemobject, &pems) ; - return r ; + return -1 ; } -- cgit v1.2.3