| ... | @@ -2158,8 +2158,11 @@ pub const Allocating = struct { | ... | @@ -2158,8 +2158,11 @@ pub const Allocating = struct { |
| 2158 | var list = a.toArrayList(); | 2158 | var list = a.toArrayList(); |
| 2159 | defer setArrayList(a, list); | 2159 | defer setArrayList(a, list); |
| 2160 | const start_len = list.items.len; | 2160 | const start_len = list.items.len; |
| | 2161 | // Even if we append no data, this function needs to ensure there is more |
| | 2162 | // capacity in the buffer to avoid infinite loop, hence the +1 in this loop. |
| | 2163 | assert(data.len != 0); |
| 2161 | for (data) |bytes| { | 2164 | for (data) |bytes| { |
| 2162 | list.ensureUnusedCapacity(gpa, bytes.len + splat_len) catch return error.WriteFailed; | 2165 | list.ensureUnusedCapacity(gpa, bytes.len + splat_len + 1) catch return error.WriteFailed; |
| 2163 | list.appendSliceAssumeCapacity(bytes); | 2166 | list.appendSliceAssumeCapacity(bytes); |
| 2164 | } | 2167 | } |
| 2165 | if (splat == 0) { | 2168 | if (splat == 0) { |