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 <david.horstmann@arm.com>
diff --git a/library/oid.c b/library/oid.c
index ea1e70b..87e5d89 100644
--- a/library/oid.c
+++ b/library/oid.c
@@ -957,6 +957,8 @@
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 @@
}
}
- 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;