Skip to content

Commit 5eee684

Browse files
committed
Add comment and additional debug check
1 parent 65e0052 commit 5eee684

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cpp/src/parquet/decoder.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,8 @@ class PlainByteArrayDecoder : public PlainDecoder<ByteArrayType> {
776776
// This precondition follows from those two checks.
777777
DCHECK_GE(len_, 4);
778778
auto value_len = SafeLoadAs<int32_t>(data_);
779+
// `value_len <= estimated_data_length` is stricter than `value_len <= len_ - 4`
780+
// due to the way `estimated_data_length` is computed.
779781
if (ARROW_PREDICT_FALSE(value_len < 0 || value_len > estimated_data_length)) {
780782
return Status::Invalid(
781783
"Invalid or truncated PLAIN-encoded BYTE_ARRAY data");
@@ -789,6 +791,7 @@ class PlainByteArrayDecoder : public PlainDecoder<ByteArrayType> {
789791
DCHECK_GE(estimated_data_length, 0);
790792
}
791793
values_decoded += static_cast<int>(run_length);
794+
DCHECK_LE(values_decoded, num_values);
792795
return Status::OK();
793796
} else {
794797
return helper->AppendNulls(run_length);

0 commit comments

Comments
 (0)