summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
Diffstat (limited to 'strings')
-rw-r--r--strings/CMakeLists.txt2
-rw-r--r--strings/ctype-uca.c22
-rw-r--r--strings/decimal.c4
3 files changed, 25 insertions, 3 deletions
diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt
index 6291d107d90..1e364bc951b 100644
--- a/strings/CMakeLists.txt
+++ b/strings/CMakeLists.txt
@@ -26,7 +26,7 @@ SET(STRINGS_SOURCES bchange.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c
my_strchr.c strcont.c strappend.c)
IF(NOT HAVE_STRNLEN)
- # OSX does not have strnlen
+ # OSX below 10.7 did not have strnlen
SET(STRINGS_SOURCES ${STRINGS_SOURCES} strnlen.c)
ENDIF()
# Avoid dependencies on perschema data defined in mysys
diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c
index 60de0a106a1..2351ee9d932 100644
--- a/strings/ctype-uca.c
+++ b/strings/ctype-uca.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2004, 2013, Oracle and/or its affiliates.
- Copyright (c) 2009, 2014, SkySQL Ab.
+ Copyright (c) 2009, 2015, MariaDB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -20583,7 +20583,25 @@ static int my_uca_scanner_next_any(my_uca_scanner *scanner)
if (((mblen= scanner->cs->cset->mb_wc(scanner->cs, wc,
scanner->sbeg,
scanner->send)) <= 0))
- return -1;
+ {
+ if (scanner->sbeg >= scanner->send)
+ return -1; /* No more bytes, end of line reached */
+ /*
+ There are some more bytes left. Non-positive mb_len means that
+ we got an incomplete or a bad byte sequence. Consume mbminlen bytes.
+ */
+ if ((scanner->sbeg+= scanner->cs->mbminlen) > scanner->send)
+ {
+ /* For safety purposes don't go beyond the string range. */
+ scanner->sbeg= scanner->send;
+ }
+ /*
+ Treat every complete or incomplete mbminlen unit as a weight which is
+ greater than weight for any possible normal character.
+ 0xFFFF is greater than any possible weight in the UCA weight table.
+ */
+ return 0xFFFF;
+ }
scanner->sbeg+= mblen;
if (wc[0] > scanner->level->maxchar)
diff --git a/strings/decimal.c b/strings/decimal.c
index 979f1b179f9..da47727bd9c 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1024,7 +1024,11 @@ int ulonglong2decimal(ulonglong from, decimal_t *to)
int longlong2decimal(longlong from, decimal_t *to)
{
if ((to->sign= from < 0))
+ {
+ if (from == LONGLONG_MIN) // avoid undefined behavior
+ return ull2dec((ulonglong)LONGLONG_MIN, to);
return ull2dec(-from, to);
+ }
return ull2dec(from, to);
}