Skip to content

Commit 10f2c9c

Browse files
authored
GH-46417: [C++][Parquet] Fix UB in LoadEnumSafe for EdgeInterpolationAlgorithm (#46418)
### Rationale for this change The previous fix ( #46307 ) introduce an another ub. ### What changes are included in this PR? Fix the ub with `internal::LoadEnumRaw` which casts enum to int. ### Are these changes tested? Covered by existing ### Are there any user-facing changes? no * GitHub Issue: #46417 Authored-by: mwish <[email protected]> Signed-off-by: mwish <[email protected]>
1 parent 9a66bdc commit 10f2c9c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cpp/src/parquet/thrift_internal.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,9 @@ inline typename Compression::type LoadEnumSafe(const format::CompressionCodec::t
242242

243243
inline typename LogicalType::EdgeInterpolationAlgorithm LoadEnumSafe(
244244
const format::EdgeInterpolationAlgorithm::type* in) {
245-
if (ARROW_PREDICT_FALSE(*in < format::EdgeInterpolationAlgorithm::SPHERICAL ||
246-
*in > format::EdgeInterpolationAlgorithm::KARNEY)) {
245+
const auto raw_value = internal::LoadEnumRaw(in);
246+
if (ARROW_PREDICT_FALSE(raw_value < format::EdgeInterpolationAlgorithm::SPHERICAL ||
247+
raw_value > format::EdgeInterpolationAlgorithm::KARNEY)) {
247248
return LogicalType::EdgeInterpolationAlgorithm::UNKNOWN;
248249
}
249250
return FromThriftUnsafe(*in);

0 commit comments

Comments
 (0)