google/protobuf — pull request #39 by xfxyjwf (2014-10-02 01:35:25+00:00)
Title: Fix descriptor validation logic for packed enum fields.

Reviewers: @pherl @protobufel

Fixes #24

The original validation code tries to access the "FieldDescriptor.type" field which for enum fields may only be available after cross-link and thus may result in a NullPointerException. This change fixes the problem by moving the validation logic to the cross-link phase.

Note that this problem only occurs for users who manually construct FileDescriptorProto. The FileDescriptorProto generated by protocol compiler already has the "type" field filled even for enum/message/group fields so it doesn't have such problems.