Skip to content

Commit 068fc78

Browse files
grooverdanDaveGosselin-MariaDB
authored andcommitted
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.
1 parent 36dfe08 commit 068fc78

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

sql/item_geofunc.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,12 +3035,19 @@ const uint8_t Item_func_latlongfromgeohash::geohash_alphabet[256] = {
30353035
};
30363036

30373037

3038+
/**
3039+
converts a geohash character to an int.
3040+
@return false on success, true on valid (invalid geohash character)
3041+
*/
30383042
bool Item_func_latlongfromgeohash::convert_character(char in, int &out)
30393043
{
3044+
#if CHAR_MIN
3045+
/* representing signed char, unsigned char always has a map */
30403046
if (in < 0)
30413047
return true;
3048+
#endif
30423049
out= Item_func_latlongfromgeohash::geohash_alphabet[(int) in];
3043-
return false;
3050+
return out == 255;
30443051
}
30453052

30463053

@@ -3071,10 +3078,8 @@ bool Item_func_latlongfromgeohash::decode_geohash(
30713078
for (uint i = 0; i < input_length; i++)
30723079
{
30733080
int converted_character= -1;
3074-
if (convert_character((*geohash)[i], converted_character) ||
3075-
converted_character == 255) {
3081+
if (convert_character((*geohash)[i], converted_character))
30763082
return true;
3077-
}
30783083

30793084
for (int bit_number = 4; bit_number >= 0; bit_number--)
30803085
{

0 commit comments

Comments
 (0)