apache / arrow

Apache Arrow is the universal columnar format and multi-language toolbox for fast data interchange and in-memory analytics
https://arrow.apache.org/
Apache License 2.0
14.63k stars 3.56k forks source link

GH-44690: [C++] NumericBuilder::AppendValues append vector prevent from ub #44794

Closed mapleFU closed 1 day ago

mapleFU commented 1 day ago

Rationale for this change

Add boundary check for NumericBuilder::AppendValues for std::vector

Originally, it will :

  1. AppendValues might has std::vector as arguments, std::vector::data might be used
  2. std::vector::data might returns nullptr if size == 0: https://en.cppreference.com/w/cpp/container/vector/data
  3. https://en.cppreference.com/w/cpp/string/byte/memcpy memcpy says, "If either dest or src is an invalid or null pointer, the behavior is undefined, even if count is zero."

What changes are included in this PR?

Add boundary check for NumericBuilder::AppendValues for std::vector

Are these changes tested?

Covered by existing

Are there any user-facing changes?

no

github-actions[bot] commented 1 day ago

:warning: GitHub issue #44690 has been automatically assigned in GitHub to PR creator.

conbench-apache-arrow[bot] commented 1 day ago

After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 501418ece4392b8059151b0d4c3ea174ab2996a2.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.