-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Open
Labels
Description
Describe the bug, including details regarding any error messages, version, and platform.
In function arrow::compute::MakeExecBatch it checks for the input Datum's type id:
arrow/cpp/src/arrow/compute/expression.cc
Line 690 in 5eaf553
| if (partial.type()->id() == Type::STRUCT) { |
Datum::type() can return null pointers. This will happen when the Datum is constructed from a record batch or a table:
Lines 76 to 88 in 5eaf553
| const std::shared_ptr<DataType>& Datum::type() const { | |
| if (this->kind() == Datum::ARRAY) { | |
| return std::get<std::shared_ptr<ArrayData>>(this->value)->type; | |
| } | |
| if (this->kind() == Datum::CHUNKED_ARRAY) { | |
| return std::get<std::shared_ptr<ChunkedArray>>(this->value)->type(); | |
| } | |
| if (this->kind() == Datum::SCALAR) { | |
| return std::get<std::shared_ptr<Scalar>>(this->value)->type; | |
| } | |
| static std::shared_ptr<DataType> no_type; | |
| return no_type; | |
| } |
However, the MakeExecBatch function does not check whether the datum is a table before Datum::type() is used. This leads to a null pointer dereference when the id() function is called.
I suggest we additionally check that Datum::type() does not return a null pointer before calling id() on it.
Component(s)
C++