loci: read and validate field-length members
diff --git a/c_gen/templates/loci_validator.c b/c_gen/templates/loci_validator.c
index 92846c2..db99336 100644
--- a/c_gen/templates/loci_validator.c
+++ b/c_gen/templates/loci_validator.c
@@ -111,8 +111,13 @@
     }
 
     len = wire_len;
+
 :: elif type(m) == OFFieldLengthMember:
+:: # Read field length members
 :: field_length_members[m.field_name] = m
+    ${types[m.length]} wire_len_${m.field_name};
+    ${readers[m.length]}(data + ${m.offset}, &wire_len_${m.field_name});
+
 :: #endif
 :: #endfor
 
@@ -131,9 +136,16 @@
     }
 :: #endif
 
-:: # Validate fixed-offset lists
 :: for m in ofclass.members:
+:: # Validate field-length members
+:: if type(m) == OFDataMember and m.name in field_length_members and m.offset is not None:
+    if (${m.offset} + wire_len_${m.name} > len) {
+        return -1;
+    }
+
+:: #endif
 :: if type(m) == OFDataMember and m.oftype.startswith('list') and m.offset is not None:
+:: # Validate fixed-offset lists
 :: if m.name in field_length_members:
 :: continue # TODO handle field length members
 :: #endif