Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cpp/src/arrow/ipc/reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <flatbuffers/flatbuffers.h> // IWYU pragma: export

#include "arrow/array.h"
#include "arrow/array/validate.h"
#include "arrow/buffer.h"
#include "arrow/extension_type.h"
#include "arrow/io/caching.h"
Expand Down Expand Up @@ -455,6 +456,21 @@ class ArrayLoader {

Status Visit(const MapType& type) {
RETURN_NOT_OK(LoadList(type));
if (!out_->child_data.empty()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can turn this into a

    DCHECK_EQ(out_->child_data.size(), 1);

after LoadList succeeds without an error

// Ensure that GetNullCount() calls in MapArray::ValidateChildData
// don't access invalid memory.
Comment on lines +460 to +461

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because when null_count == -1, it will be inferred from the unvalidated data? Can we add a (non-fuzzing based) test for this directly?

// We cannot call array validation as it will fail on non-native endianness
// (due to checking the last offset on variable-width data) or missing
// dictionaries (they are not yet populated at this point).
const ArrayData& child_data = *out_->child_data[0];
if (child_data.null_count != 0) {
return Status::Invalid("Map array child array should have no nulls");
}
if (!child_data.child_data.empty() && child_data.child_data[0]->null_count != 0) {
return Status::Invalid("Map array keys array should have no nulls");
}
}
// If we don't do this, MapArray::SetData will abort on invalid data.
return MapArray::ValidateChildData(out_->child_data);
}

Expand Down
Loading