genDeepNesting returns deeply-nested JSON array bytes. When closed is true the structure is complete ([[[...1...]]]); when false it is left unclosed ([[[..., which is the more dangerous stack-overflow shape because the parser must descend before discovering the missing closers.
(depth int, closed bool)
| 137 | // ([[[..., which is the more dangerous stack-overflow shape because the |
| 138 | // parser must descend before discovering the missing closers. |
| 139 | func genDeepNesting(depth int, closed bool) []byte { |
| 140 | buf := make([]byte, 0, depth*2+1) |
| 141 | for i := 0; i < depth; i++ { |
| 142 | buf = append(buf, '[') |
| 143 | } |
| 144 | if closed { |
| 145 | buf = append(buf, '1') |
| 146 | for i := 0; i < depth; i++ { |
| 147 | buf = append(buf, ']') |
| 148 | } |
| 149 | } |
| 150 | return buf |
| 151 | } |
| 152 | |
| 153 | // ============================================================================= |
| 154 | // Gate A: NO-PANIC (embedded in every gate via encodingJSONNoPanic) |
no outgoing calls
no test coverage detected