Check projection budgets before container allocation
This commit is contained in:
@@ -137,7 +137,9 @@ func (o *valueOperation) projectStruct(value reflect.Value, descriptor *typeDesc
|
||||
if isNilValue(memberValue) {
|
||||
continue
|
||||
}
|
||||
o.nodeCredits++
|
||||
inline, issue := o.project(memberValue, member.descriptor, path, depth)
|
||||
o.nodeCredits--
|
||||
if issue != nil {
|
||||
return nil, issue
|
||||
}
|
||||
@@ -193,6 +195,9 @@ func (o *valueOperation) projectMap(value reflect.Value, descriptor *typeDescrip
|
||||
if issue != nil {
|
||||
return nil, issue
|
||||
}
|
||||
if issue := o.checkMinimumChildren(path, value.Len(), 2); issue != nil {
|
||||
return nil, issue
|
||||
}
|
||||
result.Mapping = make([]document.Entry, 0, value.Len())
|
||||
keys := value.MapKeys()
|
||||
slices.SortFunc(keys, func(left, right reflect.Value) int {
|
||||
@@ -217,6 +222,9 @@ func (o *valueOperation) projectSequence(value reflect.Value, descriptor *typeDe
|
||||
if issue != nil {
|
||||
return nil, issue
|
||||
}
|
||||
if issue := o.checkMinimumChildren(path, value.Len(), 1); issue != nil {
|
||||
return nil, issue
|
||||
}
|
||||
result.Sequence = make([]*document.Node, 0, value.Len())
|
||||
for index := 0; index < value.Len(); index++ {
|
||||
childPath := path.Index(index)
|
||||
|
||||
Reference in New Issue
Block a user