| 98 | } |
| 99 | |
| 100 | func (u *unmarshalGen) assignMap(name string, base string, fieldLimit uint32) { |
| 101 | if !u.p.ok() { |
| 102 | return |
| 103 | } |
| 104 | u.p.printf("\n%s, bts, err = msgp.Read%sBytes(bts)", name, base) |
| 105 | u.p.wrapErrCheck(u.ctx.ArgsStr()) |
| 106 | |
| 107 | // Determine effective limit: field limit > context field limit > file limit |
| 108 | var limit uint32 |
| 109 | var limitName string |
| 110 | |
| 111 | if fieldLimit > 0 { |
| 112 | // Explicit field limit passed as parameter |
| 113 | limit = fieldLimit |
| 114 | limitName = fmt.Sprintf("%d", fieldLimit) |
| 115 | } else if u.ctx.currentFieldMapLimit != math.MaxUint32 { |
| 116 | // Field limit from context (set during field processing) |
| 117 | limit = u.ctx.currentFieldMapLimit |
| 118 | limitName = fmt.Sprintf("%d", u.ctx.currentFieldMapLimit) |
| 119 | } else if u.ctx.mapLimit != math.MaxUint32 { |
| 120 | // File-level limit |
| 121 | limit = u.ctx.mapLimit |
| 122 | limitName = fmt.Sprintf("%slimitMaps", u.ctx.limitPrefix) |
| 123 | } |
| 124 | |
| 125 | if limit > 0 && limit != math.MaxUint32 { |
| 126 | u.p.printf("\nif %s > %s {", name, limitName) |
| 127 | u.p.printf("\nerr = msgp.ErrLimitExceeded") |
| 128 | u.p.printf("\nreturn") |
| 129 | u.p.printf("\n}") |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | // Returns whether a nil check should be done |
| 134 | func (u *unmarshalGen) readBytesWithLimit(refname, lowered string, zerocopy bool, fieldLimit uint32) bool { |