(name string, typ string, fieldLimit uint32)
| 109 | } |
| 110 | |
| 111 | func (d *decodeGen) assignMap(name string, typ string, fieldLimit uint32) { |
| 112 | if !d.p.ok() { |
| 113 | return |
| 114 | } |
| 115 | d.p.printf("\n%s, err = dc.Read%s()", name, typ) |
| 116 | d.p.wrapErrCheck(d.ctx.ArgsStr()) |
| 117 | |
| 118 | // Determine effective limit: field limit > context field limit > file limit |
| 119 | var limit uint32 |
| 120 | var limitName string |
| 121 | |
| 122 | if fieldLimit > 0 { |
| 123 | // Explicit field limit passed as parameter |
| 124 | limit = fieldLimit |
| 125 | limitName = fmt.Sprintf("%d", fieldLimit) |
| 126 | } else if d.ctx.currentFieldMapLimit != math.MaxUint32 { |
| 127 | // Field limit from context (set during field processing) |
| 128 | limit = d.ctx.currentFieldMapLimit |
| 129 | limitName = fmt.Sprintf("%d", d.ctx.currentFieldMapLimit) |
| 130 | } else if d.ctx.mapLimit != math.MaxUint32 { |
| 131 | // File-level limit |
| 132 | limit = d.ctx.mapLimit |
| 133 | limitName = fmt.Sprintf("%slimitMaps", d.ctx.limitPrefix) |
| 134 | } |
| 135 | |
| 136 | if limit > 0 && limit != math.MaxUint32 { |
| 137 | d.p.printf("\nif %s > %s {", name, limitName) |
| 138 | d.p.printf("\nerr = msgp.ErrLimitExceeded") |
| 139 | d.p.printf("\nreturn") |
| 140 | d.p.printf("\n}") |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | // readBytesWithLimit will read bytes into vname. |
| 145 | // Returns field to check for nil. |
no test coverage detected