From 3f6d522a01edbf690d7d89467c4eb7e03e6b9df9 Mon Sep 17 00:00:00 2001 From: Jorge Leitao Date: Mon, 10 Jan 2022 07:30:23 +0100 Subject: [PATCH] Removed last assert from IPC read (#748) --- src/io/ipc/read/read_basic.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/io/ipc/read/read_basic.rs b/src/io/ipc/read/read_basic.rs index 03abaa92de9..d442a82b665 100644 --- a/src/io/ipc/read/read_basic.rs +++ b/src/io/ipc/read/read_basic.rs @@ -163,8 +163,15 @@ fn read_uncompressed_bitmap( bytes: usize, reader: &mut R, ) -> Result> { - // something is wrong if we can't `length` - assert!(length <= bytes * 8); + if length > bytes * 8 { + return Err(ArrowError::OutOfSpec(format!( + "An array requires a bitmap with at least the same number of bits as slots. \ + However, this array reports {} slots but the the bitmap in IPC only contains \ + {} bits", + length, + bytes * 8, + ))); + } // it is undefined behavior to call read_exact on un-initialized, https://doc.rust-lang.org/std/io/trait.Read.html#tymethod.read // see also https://github.com/MaikKlein/ash/issues/354#issue-781730580 let mut buffer = vec![0; bytes];