From 543bc635ab207b8a84acbec841fd4550df872e0f Mon Sep 17 00:00:00 2001 From: Raphael Taylor-Davies Date: Sun, 16 Oct 2022 08:11:04 +1300 Subject: [PATCH] Validate decimal IPC read (#2387) --- arrow/src/ipc/reader.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/arrow/src/ipc/reader.rs b/arrow/src/ipc/reader.rs index a784f54e20c..63c587455d5 100644 --- a/arrow/src/ipc/reader.rs +++ b/arrow/src/ipc/reader.rs @@ -486,16 +486,12 @@ fn create_primitive_array( .unwrap(), Decimal128(_, _) | Decimal256(_, _) => { // read 2 buffers: null buffer (optional) and data buffer - let builder = ArrayData::builder(data_type.clone()) + ArrayData::builder(data_type.clone()) .len(length) .add_buffer(buffers[1].clone()) - .null_bit_buffer(null_buffer); - - // Don't validate the decimal array so far, - // becasue validating decimal is some what complicated - // and there is no conclusion on whether we should do it. - // For more infomation, please look at https://github.com/apache/arrow-rs/issues/2387 - unsafe { builder.build_unchecked() } + .null_bit_buffer(null_buffer) + .build() + .unwrap() } t => unreachable!("Data type {:?} either unsupported or not primitive", t), };