Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix descriptor validation logic for packed enum fields. #39

Merged
merged 1 commit into from
Oct 3, 2014
Merged

Fix descriptor validation logic for packed enum fields. #39

merged 1 commit into from
Oct 3, 2014

Conversation

xfxyjwf
Copy link
Contributor

@xfxyjwf xfxyjwf commented Oct 2, 2014

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.

@liujisi
Copy link
Contributor

liujisi commented Oct 3, 2014

LGTM

xfxyjwf added a commit that referenced this pull request Oct 3, 2014
Fix descriptor validation logic for packed enum fields.
@xfxyjwf xfxyjwf merged commit 0dd3fef into protocolbuffers:master Oct 3, 2014
@przole przole mentioned this pull request Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Descriptors$FieldDescriptor.<init>(Descriptors.java:1107) isPacked() NPE
2 participants