Fix bug: read extra fields if flags array is shorter than fields

if flags.length < fields.length, "flags[i] & 2**j != 0" will be evaluated as "nil & 2**j != 0", which is always true.