From a2f36898650278c603b96cebb400cca48ff67f8c Mon Sep 17 00:00:00 2001 From: David LeBlanc Date: Mon, 6 May 2019 19:28:25 -0700 Subject: [PATCH] Older compilers don't allow declaring variables other than at the top of the block if it is a C file. --- src/unpack.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/unpack.c b/src/unpack.c index e4468c11..d89ac29c 100644 --- a/src/unpack.c +++ b/src/unpack.c @@ -189,6 +189,7 @@ static inline int template_callback_false(unpack_user* u, msgpack_object* o) static inline int template_callback_array(unpack_user* u, unsigned int n, msgpack_object* o) { + size_t size; // Let's leverage the fact that sizeof(msgpack_object) is a compile time constant // to check for int overflows. // Note - while n is constrained to 32-bit, the product of n * sizeof(msgpack_object) @@ -199,7 +200,7 @@ static inline int template_callback_array(unpack_user* u, unsigned int n, msgpac o->type = MSGPACK_OBJECT_ARRAY; o->via.array.size = 0; - size_t size = n * sizeof(msgpack_object); + size = n * sizeof(msgpack_object); if (*u->z == NULL) { *u->z = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE); @@ -228,6 +229,7 @@ static inline int template_callback_array_item(unpack_user* u, msgpack_object* c static inline int template_callback_map(unpack_user* u, unsigned int n, msgpack_object* o) { + size_t size; // Let's leverage the fact that sizeof(msgpack_object_kv) is a compile time constant // to check for int overflows // Note - while n is constrained to 32-bit, the product of n * sizeof(msgpack_object) @@ -239,7 +241,7 @@ static inline int template_callback_map(unpack_user* u, unsigned int n, msgpack_ o->type = MSGPACK_OBJECT_MAP; o->via.map.size = 0; - size_t size = n * sizeof(msgpack_object_kv); + size = n * sizeof(msgpack_object_kv); if (*u->z == NULL) { *u->z = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);