mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-01 11:58:21 +00:00
internal/impl: fix off-by-one error in message initialization
This particular off-by-one can never happen in practice. We will crash if a field has a number one greater than the maximum field number in the dense array, but if field number N is in the array we will always put N+1 in it as well. Fix the off-by-one anyway. Change-Id: I8c1304f2fc0d7b91036bde3f7ddb7115c21781ca Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/229278 Reviewed-by: Joe Tsai <joetsai@google.com>
This commit is contained in:
parent
98f56d1bd5
commit
a5526f0129
@ -136,7 +136,7 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
}
|
||||
mi.denseCoderFields = make([]*coderFieldInfo, maxDense+1)
|
||||
for _, cf := range mi.orderedCoderFields {
|
||||
if int(cf.num) > len(mi.denseCoderFields) {
|
||||
if int(cf.num) >= len(mi.denseCoderFields) {
|
||||
break
|
||||
}
|
||||
mi.denseCoderFields[cf.num] = cf
|
||||
|
Loading…
Reference in New Issue
Block a user