alltypes test case: cover the logic needed for multiple fixed length arrays
diff --git a/tests/alltypes/alltypes.options b/tests/alltypes/alltypes.options
index ee57bc0..b3a7eb0 100644
--- a/tests/alltypes/alltypes.options
+++ b/tests/alltypes/alltypes.options
@@ -2,6 +2,7 @@
 * max_count:5
 *.*fbytes fixed_length:true max_size:4
 *.*farray fixed_count:true max_count:5
+*.*farray2 fixed_count:true max_count:3
 IntSizes.*int8 int_size:IS_8
 IntSizes.*int16 int_size:IS_16
 DescriptorSize8 descriptorsize:DS_8
diff --git a/tests/alltypes/alltypes.proto b/tests/alltypes/alltypes.proto
index 317b783..a7e2747 100644
--- a/tests/alltypes/alltypes.proto
+++ b/tests/alltypes/alltypes.proto
@@ -136,6 +136,9 @@
 
     optional NonZeroBasedEnum opt_non_zero_based_enum = 62;
     
+    // Second fixed length array field to test the length check logic.
+    repeated fixed32 rep_farray2 = 95 [packed = true];
+
     // Check support for custom integer sizes
     required IntSizes req_intsizes = 96;
 
diff --git a/tests/alltypes/decode_alltypes.c b/tests/alltypes/decode_alltypes.c
index 3b92614..e431f35 100644
--- a/tests/alltypes/decode_alltypes.c
+++ b/tests/alltypes/decode_alltypes.c
@@ -86,6 +86,7 @@
         TEST(memcmp(alltypes.rep_fbytes[4], "2019", 4) == 0);
 
         TEST(alltypes.rep_farray[0] == 0 && alltypes.rep_farray[4] == 2040);
+        TEST(alltypes.rep_farray2[0] == 0 && alltypes.rep_farray2[2] == 2095);
 
         TEST(alltypes.req_limits.int32_min  == INT32_MIN);
         TEST(alltypes.req_limits.int32_max  == INT32_MAX);
diff --git a/tests/alltypes/encode_alltypes.c b/tests/alltypes/encode_alltypes.c
index 7f4ad2b..6067c54 100644
--- a/tests/alltypes/encode_alltypes.c
+++ b/tests/alltypes/encode_alltypes.c
@@ -77,6 +77,7 @@
         memcpy(alltypes.rep_fbytes[4], "2019", 4);
         
         alltypes.rep_farray[4] = 2040;
+        alltypes.rep_farray2[2] = 2095;
 
         alltypes.req_limits.int32_min  = INT32_MIN;
         alltypes.req_limits.int32_max  = INT32_MAX;
diff --git a/tests/alltypes_callback/encode_alltypes_callback.c b/tests/alltypes_callback/encode_alltypes_callback.c
index d123bf7..79b5713 100644
--- a/tests/alltypes_callback/encode_alltypes_callback.c
+++ b/tests/alltypes_callback/encode_alltypes_callback.c
@@ -227,6 +227,19 @@
            pb_encode_submessage(stream, EmptyMessage_fields, &emptymsg);
 }
 
+static bool write_farray2(pb_ostream_t *stream, const pb_field_t *field, void * const *arg)
+{
+    uint32_t dummy = 0;
+    uint32_t value = (uint32_t)(intptr_t)*arg;
+
+    /* Make it a packed field */
+    return pb_encode_tag(stream, PB_WT_STRING, field->tag) &&
+           pb_encode_varint(stream, 3 * 4) && /* Number of bytes */
+           pb_encode_fixed32(stream, &dummy) &&
+           pb_encode_fixed32(stream, &dummy) &&
+           pb_encode_fixed32(stream, &value);
+}
+
 int main(int argc, char **argv)
 {
     int mode = (argc > 1) ? atoi(argv[1]) : 0;
@@ -380,6 +393,9 @@
     alltypes.rep_farray.funcs.encode = &write_repeated_varint;
     alltypes.rep_farray.arg = (void*)2040;
 
+    alltypes.rep_farray2.funcs.encode = &write_farray2;
+    alltypes.rep_farray2.arg = (void*)2095;
+
     alltypes.req_limits.funcs.encode = &write_limits;
     
     alltypes.req_ds8.funcs.encode = &write_ds8;
diff --git a/tests/alltypes_pointer/alltypes.options b/tests/alltypes_pointer/alltypes.options
index eca839c..75cff8d 100644
--- a/tests/alltypes_pointer/alltypes.options
+++ b/tests/alltypes_pointer/alltypes.options
@@ -2,6 +2,7 @@
 * type:FT_POINTER
 *.*fbytes fixed_length:true max_size:4
 *.*farray fixed_count:true max_count:5
+*.*farray2 fixed_count:true max_count:3
 IntSizes.*int8 int_size:IS_8
 IntSizes.*int16 int_size:IS_16
 DescriptorSize8 descriptorsize:DS_8
diff --git a/tests/alltypes_pointer/decode_alltypes_pointer.c b/tests/alltypes_pointer/decode_alltypes_pointer.c
index f652b17..d1ac1a3 100644
--- a/tests/alltypes_pointer/decode_alltypes_pointer.c
+++ b/tests/alltypes_pointer/decode_alltypes_pointer.c
@@ -77,6 +77,7 @@
     TEST(alltypes.rep_fbytes[0][0] == 0 && alltypes.rep_fbytes[0][3] == 0);
     TEST(memcmp(alltypes.rep_fbytes[4], "2019", 4) == 0);
     TEST(alltypes.rep_farray && (*alltypes.rep_farray)[0] == 0 && (*alltypes.rep_farray)[4] == 2040);
+    TEST(alltypes.rep_farray2 && (*alltypes.rep_farray2)[0] == 0 && (*alltypes.rep_farray2)[2] == 2095);
 
     if (mode == 0)
     {
diff --git a/tests/alltypes_pointer/encode_alltypes_pointer.c b/tests/alltypes_pointer/encode_alltypes_pointer.c
index 7f4b391..cb5c5df 100644
--- a/tests/alltypes_pointer/encode_alltypes_pointer.c
+++ b/tests/alltypes_pointer/encode_alltypes_pointer.c
@@ -65,6 +65,7 @@
     EmptyMessage rep_emptymsg[5]  = {{0}, {0}, {0}, {0}, {0}};
     pb_byte_t   rep_fbytes[5][4]  = {{0}, {0}, {0}, {0}, {'2', '0', '1', '9'}};
     int32_t     rep_farray[5]     = {0, 0, 0, 0, 2040};
+    uint32_t    rep_farray2[3]    = {0, 0, 2095};
 
     /* Values for optional fields */
     int32_t     opt_int32         = 3041;
@@ -173,6 +174,7 @@
     alltypes.rep_emptymsg_count = 5; alltypes.rep_emptymsg  = rep_emptymsg;
     alltypes.rep_fbytes_count   = 5; alltypes.rep_fbytes    = rep_fbytes;
     alltypes.rep_farray = &rep_farray;
+    alltypes.rep_farray2 = &rep_farray2;
     
     if (mode != 0)
     {
diff --git a/tests/common_unittests/common_unittests.c b/tests/common_unittests/common_unittests.c
index fabe67c..63656dd 100644
--- a/tests/common_unittests/common_unittests.c
+++ b/tests/common_unittests/common_unittests.c
@@ -93,6 +93,10 @@
 
         TEST(pb_field_iter_next(&iter) && iter.tag == 62 && iter.pData == &msg.opt_non_zero_based_enum && iter.pSize == &msg.has_opt_non_zero_based_enum)
 
+        TEST(pb_field_iter_next(&iter) && iter.tag == 95 && iter.pData == &msg.rep_farray2 && iter.pSize == &iter.array_size && iter.array_size == 3)
+        TEST(iter.required_field_index == 19)
+        TEST(iter.submessage_index == 8)
+
         TEST(pb_field_iter_next(&iter) && iter.tag == 96 && iter.pData == &msg.req_intsizes && !iter.pSize)
         TEST(iter.required_field_index == 19)
         TEST(iter.submessage_index == 8)
diff --git a/tests/field_size_16/alltypes.options b/tests/field_size_16/alltypes.options
index a1e1fa2..8de9d8c 100644
--- a/tests/field_size_16/alltypes.options
+++ b/tests/field_size_16/alltypes.options
@@ -2,5 +2,6 @@
 * max_count:5
 *.*fbytes fixed_length:true max_size:4
 *.*farray fixed_count:true max_count:5
+*.*farray2 fixed_count:true max_count:3
 DescriptorSize8 descriptorsize:DS_8
 
diff --git a/tests/field_size_16/alltypes.proto b/tests/field_size_16/alltypes.proto
index 9191ca0..28c6d05 100644
--- a/tests/field_size_16/alltypes.proto
+++ b/tests/field_size_16/alltypes.proto
@@ -135,6 +135,9 @@
 
     optional NonZeroBasedEnum opt_non_zero_based_enum = 10062;
 
+    // Second fixed length array field to test the length check logic.
+    repeated fixed32 rep_farray2 = 95 [packed = true];
+
     // Check support for custom integer sizes
     required IntSizes req_intsizes = 96;
 
diff --git a/tests/field_size_32/alltypes.options b/tests/field_size_32/alltypes.options
index 5d9f81e..82e7ada 100644
--- a/tests/field_size_32/alltypes.options
+++ b/tests/field_size_32/alltypes.options
@@ -2,4 +2,5 @@
 * max_count:5
 *.*fbytes fixed_length:true max_size:4
 *.*farray fixed_count:true max_count:5
+*.*farray2 fixed_count:true max_count:3
 DescriptorSize8 descriptorsize:DS_8
diff --git a/tests/field_size_32/alltypes.proto b/tests/field_size_32/alltypes.proto
index 2ae0f1f..35e6feb 100644
--- a/tests/field_size_32/alltypes.proto
+++ b/tests/field_size_32/alltypes.proto
@@ -135,6 +135,9 @@
 
     optional NonZeroBasedEnum opt_non_zero_based_enum = 10062;
 
+    // Second fixed length array field to test the length check logic.
+    repeated fixed32 rep_farray2 = 95 [packed = true];
+
     // Check support for custom integer sizes
     required IntSizes req_intsizes = 96;