Skip to content

Commit 7e3077e

Browse files
committed
chore
1 parent 1ffd2c0 commit 7e3077e

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

arrow-json/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ harness = false
6868

6969
[[bench]]
7070
name = "reader"
71-
harness = false
71+
harness = false

arrow-json/src/reader/struct_array.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ impl StructArrayDecoder {
5959
)
6060
})
6161
.collect::<Result<Vec<_>, ArrowError>>()?;
62-
let field_name_to_index = build_field_index(fields);
62+
let field_name_to_index = if struct_mode == StructMode::ObjectOnly {
63+
build_field_index(fields)
64+
} else {
65+
None
66+
};
6367
(decoders, field_name_to_index)
6468
};
6569

@@ -80,7 +84,20 @@ impl ArrayDecoder for StructArrayDecoder {
8084
let fields = struct_fields(&self.data_type);
8185
let row_count = pos.len();
8286
let field_count = fields.len();
83-
let total_len = field_count * row_count;
87+
let total_len = field_count.checked_mul(row_count).ok_or_else(|| {
88+
ArrowError::JsonError(format!(
89+
"StructArrayDecoder child position buffer size overflow for rows={row_count} fields={field_count}"
90+
))
91+
})?;
92+
if total_len > self.child_pos.len() {
93+
self.child_pos
94+
.try_reserve(total_len - self.child_pos.len())
95+
.map_err(|_| {
96+
ArrowError::JsonError(format!(
97+
"StructArrayDecoder child position buffer allocation failed for rows={row_count} fields={field_count}"
98+
))
99+
})?;
100+
}
84101
self.child_pos.resize(total_len, 0);
85102
self.child_pos.fill(0);
86103
let mut nulls = self

0 commit comments

Comments
 (0)