Skip to content

Commit

Permalink
ARROW-13810: [C++][Compute] Predicate IsAsciiCharacter allows invalid…
Browse files Browse the repository at this point in the history
… types and values

Remove template from string predicate IsAsciiCharacter to prevent returning true for invalid types and values.

Closes apache#11048 from edponce/ARROW-13810-Compute-Predicate-IsAsciiCharacter-allow

Authored-by: Eduardo Ponce <edponce00@gmail.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
edponce authored and Matthew Topol committed Sep 12, 2021
1 parent 1c3e5b8 commit 6b6f1ef
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions cpp/src/arrow/compute/kernels/scalar_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ Status RegexStatus(const RE2& regex) {

// IsAlpha/Digit etc

template <typename T>
static inline bool IsAsciiCharacter(T character) {
return character < 128;
}
static inline bool IsAsciiCharacter(uint8_t character) { return character < 128; }

static inline bool IsLowerCaseCharacterAscii(uint8_t ascii_character) {
return (ascii_character >= 'a') && (ascii_character <= 'z');
Expand Down Expand Up @@ -1746,8 +1743,7 @@ struct IsNumericUnicode : CharacterPredicateUnicode<IsNumericUnicode> {
struct IsAscii {
static bool Call(KernelContext*, const uint8_t* input,
size_t input_string_nascii_characters, Status*) {
return std::all_of(input, input + input_string_nascii_characters,
IsAsciiCharacter<uint8_t>);
return std::all_of(input, input + input_string_nascii_characters, IsAsciiCharacter);
}
};

Expand Down

0 comments on commit 6b6f1ef

Please sign in to comment.