From 6883358c16f2e369129753d3999bb345e57c3f29 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Wed, 31 May 2023 17:27:28 +0100 Subject: [PATCH] Hoist variable declarations to before goto This should appease IAR, which does not like declarations in the middle of goto sequences. Signed-off-by: David Horstmann --- library/oid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/oid.c b/library/oid.c index ea1e70bf0..87e5d892f 100644 --- a/library/oid.c +++ b/library/oid.c @@ -957,6 +957,8 @@ int mbedtls_oid_from_numeric_string(mbedtls_asn1_buf *oid, unsigned int component1, component2; /* Count the number of dots to get a worst-case allocation size. */ size_t num_dots = 0; + size_t encoded_len; + unsigned char *minimum_mem; for (size_t i = 0; (i < size) && (oid_str[i] != '\0'); i++) { if (oid_str[i] == '.') { @@ -1040,8 +1042,8 @@ int mbedtls_oid_from_numeric_string(mbedtls_asn1_buf *oid, } } - size_t encoded_len = out_ptr - oid->p; - unsigned char *minimum_mem = mbedtls_calloc(encoded_len, 1); + encoded_len = out_ptr - oid->p; + minimum_mem = mbedtls_calloc(encoded_len, 1); if (minimum_mem == NULL) { ret = MBEDTLS_ERR_ASN1_ALLOC_FAILED; goto error;