From 3e18dfb6b0373169979b5af2bbda3875719df07c Mon Sep 17 00:00:00 2001 From: Magne Mahre Date: Wed, 11 Nov 2009 19:54:57 +0100 Subject: [PATCH] Fix of incorrect casting for large sizes --- include/m_string.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/include/m_string.h b/include/m_string.h index 264bf6d545d..3bbb7156bf1 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -311,18 +311,17 @@ typedef struct st_mysql_lex_string LEX_STRING; static inline const uchar *skip_trailing_space(const uchar *ptr,size_t len) { - const uchar *start= ptr; const uchar *end= ptr + len; if (len > 20) { - const uchar *end_words= (const uchar *) - (((intptr)end) / SIZEOF_INT * SIZEOF_INT); - const uchar *start_words= (const uchar *) - ((((intptr)start) + SIZEOF_INT - 1) / SIZEOF_INT * SIZEOF_INT); + const uchar *end_words= (const uchar *)(intptr) + (((ulonglong)(intptr)end) / SIZEOF_INT * SIZEOF_INT); + const uchar *start_words= (const uchar *)(intptr) + ((((ulonglong)(intptr)ptr) + SIZEOF_INT - 1) / SIZEOF_INT * SIZEOF_INT); - DBUG_ASSERT(((intptr)start) >= SIZEOF_INT); - if (end_words > start) + DBUG_ASSERT(((ulonglong)(intptr)ptr) >= SIZEOF_INT); + if (end_words > ptr) { while (end > end_words && end[-1] == 0x20) end--; @@ -331,7 +330,7 @@ static inline const uchar *skip_trailing_space(const uchar *ptr,size_t len) end -= SIZEOF_INT; } } - while (end > start && end[-1] == 0x20) + while (end > ptr && end[-1] == 0x20) end--; return (end); }