From 068fc787ee6ac748b498bd726eecf87159ac5b25 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 29 Apr 2025 17:00:32 +1000 Subject: [PATCH] MDEV-36168 ASAN error in Item_func_latlongfromgeohash::decode_geohash (postfix) pppc64le, aarch64, and s390x have char defined as unsigned so a < 0 comparison is a compile error. The CHAR_MIN defined in limits.h is 0 on these platforms, false, meaning the if condition is only on signed char platforms. To make the interface cleaner we return true on out == 255 to simplify the calling function. --- sql/item_geofunc.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 307b91285f8..ba9c8f06ae0 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -3035,12 +3035,19 @@ const uint8_t Item_func_latlongfromgeohash::geohash_alphabet[256] = { }; +/** + converts a geohash character to an int. + @return false on success, true on valid (invalid geohash character) +*/ bool Item_func_latlongfromgeohash::convert_character(char in, int &out) { +#if CHAR_MIN + /* representing signed char, unsigned char always has a map */ if (in < 0) return true; +#endif out= Item_func_latlongfromgeohash::geohash_alphabet[(int) in]; - return false; + return out == 255; } @@ -3071,10 +3078,8 @@ bool Item_func_latlongfromgeohash::decode_geohash( for (uint i = 0; i < input_length; i++) { int converted_character= -1; - if (convert_character((*geohash)[i], converted_character) || - converted_character == 255) { + if (convert_character((*geohash)[i], converted_character)) return true; - } for (int bit_number = 4; bit_number >= 0; bit_number--) {