| 265 | } |
| 266 | |
| 267 | Result<int64_t> GetVariadicCount(int i) { |
| 268 | auto* variadic_counts = metadata_->variadicBufferCounts(); |
| 269 | auto* buffers = metadata_->buffers(); |
| 270 | CHECK_FLATBUFFERS_NOT_NULL(variadic_counts, "RecordBatch.variadicBufferCounts"); |
| 271 | CHECK_FLATBUFFERS_NOT_NULL(buffers, "RecordBatch.buffers"); |
| 272 | if (i >= static_cast<int>(variadic_counts->size())) { |
| 273 | return Status::IOError("variadic_count_index out of range."); |
| 274 | } |
| 275 | int64_t count = variadic_counts->Get(i); |
| 276 | if (count < 0) { |
| 277 | return Status::IOError("variadic buffer count must be positive"); |
| 278 | } |
| 279 | // Detect an excessive variadic buffer count to avoid potential memory blowup |
| 280 | // (GH-48900). |
| 281 | const auto max_buffer_count = static_cast<int64_t>(buffers->size()) - buffer_index_; |
| 282 | if (count > max_buffer_count) { |
| 283 | return Status::IOError("variadic buffer count exceeds available number of buffers"); |
| 284 | } |
| 285 | return count; |
| 286 | } |
| 287 | |
| 288 | Status GetFieldMetadata(int field_index, ArrayData* out) { |
| 289 | auto nodes = metadata_->nodes(); |