(protobuf) Fix writeString(char[],int,int) writing enum values twice - #772
Open
pjfanning wants to merge 1 commit into
Open
(protobuf) Fix writeString(char[],int,int) writing enum values twice#772pjfanning wants to merge 1 commit into
writeString(char[],int,int) writing enum values twice#772pjfanning wants to merge 1 commit into
Conversation
… twice The `String` overload returns after `_writeEnum()`; the `char[]` one did not, so it emitted the enum index and then fell through and emitted the same value again as a length-prefixed String. Writing "WEB" to an enum field produced 7 bytes instead of 2, i.e. corrupt output. Adds a regression test asserting the `char[]` and `String` overloads produce identical bytes for an enum-valued field. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
pjfanning
force-pushed
the
protobuf-enum-fixes
branch
from
September 7, 2026 14:12
66c1c23 to
c1acd92
Compare
writeString(char[],int,int) writing enum values twice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
EnumLookupsizing fix that was originally in this PR has been split out into #773.ProtobufGenerator.writeString(char[],int,int)writes enum values twiceThe
Stringoverload returns after_writeEnum(); thechar[]one did not, so it emitted the enum index and then fell through and emitted the same value again as a length-prefixed String. Writing"WEB"to an enum field produced 7 bytes instead of 2, i.e. corrupt output.Pre-dates the 2.x -> 3.x rename and is present on
2.21too; targeting3.xfor now, happy to redo against2.21and merge forward if you prefer.Test
WriteEnumAsCharArrayTest— thechar[]andStringoverloads must produce identical bytes for an enum-valued field, and the result must round-trip. Confirmed it fails withexpected: <2> but was: <7>if thereturnis removed again.Full
protobufmodule test suite passes.🤖 Generated with Claude Code